void FullyConnectedMesh2::AddParticipant(SystemAddress participant) { if (rakPeerInterface->IsConnected(participant,false,false)==false) { #ifdef DEBUG_FCM2 printf("AddParticipant to %s failed (not connected)\n", participant.ToString()); #endif return; } // Account for different system addresses between different participants RakNetGUID newParticipantGuid = rakPeerInterface->GetGuidFromSystemAddress(participant); for (unsigned int i=0; i < participantList.Size(); i++) { if (participantList[i].rakNetGuid==newParticipantGuid) { if (participantList[i].systemAddress!=participant) { participantList[i].systemAddress=participant; if (ourFCMGuid==0) { SendFCMGuidRequest(participant); return; } else { SendOurFCMGuid(participant); return; } } #ifdef DEBUG_FCM2 printf("AddParticipant to %s failed (Same Guid and System address)\n", participant.ToString()); #endif // else already added return; } } // Not in the list at all if (ourFCMGuid==0) { SendFCMGuidRequest(participant); guidRequestRetryList.Push(rakPeerInterface->GetGuidFromSystemAddress(participant),__FILE__,__LINE__); } else { SendOurFCMGuid(participant); } }
void FullyConnectedMesh2::ResetHostCalculation(void) { startupTime=RakNet::GetTimeUS(); totalConnectionCount=0; ourFCMGuid=0; for (unsigned int i=0; i < participantList.Size(); i++) SendFCMGuidRequest(participantList[i].rakNetGuid); }
void FullyConnectedMesh2::OnClosedConnection(SystemAddress systemAddress, RakNetGUID rakNetGUID, PI2_LostConnectionReason lostConnectionReason ) { (void) lostConnectionReason; (void) systemAddress; (void) rakNetGUID; DataStructures::DefaultIndexType idx; idx = guidRequestRetryList.GetIndexOf(rakNetGUID); if (idx!=-1) { guidRequestRetryList.RemoveAtIndex(idx,__FILE__,__LINE__); // If ourFCMGuid is UNASSIGNED, SendFCMGuidRequest to all in guidRequestRetryList if (ourFCMGuid==0) { for (idx=0; idx < guidRequestRetryList.GetSize(); idx++) { SendFCMGuidRequest(rakPeerInterface->GetSystemAddressFromGuid(guidRequestRetryList[idx])); } } } for (idx=0; idx < participantList.Size(); idx++) { if (participantList[idx].systemAddress==systemAddress) { participantList[idx]=participantList[participantList.Size()-1]; #ifdef DEBUG_FCM2 printf("Popping participant %s\n", participantList[participantList.Size()-1].rakNetGuid.ToString()); #endif participantList.Pop(); if (systemAddress==hostSystemAddress && ourFCMGuid!=0) { if (participantList.Size()==0) { hostSystemAddress=UNASSIGNED_SYSTEM_ADDRESS; hostRakNetGuid=rakPeerInterface->GetGuidFromSystemAddress(UNASSIGNED_SYSTEM_ADDRESS); hostFCM2Guid=ourFCMGuid; } else { CalculateHost(&hostSystemAddress, &hostRakNetGuid, &hostFCM2Guid); } PushNewHost(hostSystemAddress,hostRakNetGuid); } return; } } }
bool FullyConnectedMesh2::AddParticipantInternal( RakNetGUID rakNetGuid, FCM2Guid theirFCMGuid ) { for (unsigned int i=0; i < participantList.Size(); i++) { if (participantList[i].rakNetGuid==rakNetGuid) { if (theirFCMGuid!=0) participantList[i].fcm2Guid=theirFCMGuid; return false; } } FCM2Participant participant; participant.rakNetGuid=rakNetGuid; participant.fcm2Guid=theirFCMGuid; participantList.Push(participant,__FILE__,__LINE__); SendFCMGuidRequest(rakNetGuid); return true; }