//Record change handler for initial game sync void HandleDidChangeRecordSync(string arg1, ChannelTemplate arg2, IDictionary arg3, string[] arg4) { if (arg2.receiver_id == clientID) //if this message applies to us (the receiverID is us) { clientSyncPosition = (clientStatuses)System.Enum.Parse(typeof(clientStatuses), arg2.payload); Debug.Log("client Sync position is: " + clientSyncPosition.ToString()); sessionSyncPosition = (sessionStatuses)(int)(clientSyncPosition + 1); Debug.Log("session Sync position is: " + sessionSyncPosition.ToString()); if ((int)sessionSyncPosition > (int)sessionStatuses.running) //last stage of sync is 'running' //don't broadcast anything to the client, they are running { playersSynced++; Debug.Log("One more client is fully synced!" + sessionSyncPosition + ", total: " + playersSynced); if (numberOfPlayers != playersSynced) { Debug.Log("number of players != playersSynced! numplayers: " + numberOfPlayers + ", playersSynced: " + playersSynced); } } else { Debug.Log("recieved message for sync: " + arg2.payload + "; on state: " + sessionSyncPosition); StartCoroutine(callUpdateSessionStatus(sessionSyncPosition.ToString())); } } else { Debug.Log("this message is not directed at us, senderID: " + arg2.sender_id + ", receiverID: '" + arg2.receiver_id + "', our clientID: '" + clientID + "'"); } }
//Record change handler for initial game sync void HandleDidChangeRecordSync(string arg1, ChannelTemplate arg2, IDictionary arg3, string[] arg4) { if (arg2.receiver_id == clientID) { //if this message applies to us (the receiverID is us) clientSyncPosition = (clientStatuses) System.Enum.Parse (typeof(clientStatuses), arg2.payload); Debug.Log ("client Sync position is: " + clientSyncPosition.ToString()); sessionSyncPosition = (sessionStatuses)(int)(clientSyncPosition + 1); Debug.Log ("session Sync position is: " + sessionSyncPosition.ToString()); if ((int)sessionSyncPosition > (int)sessionStatuses.running) { //last stage of sync is 'running' //don't broadcast anything to the client, they are running playersSynced++; Debug.Log ("One more client is fully synced!" + sessionSyncPosition + ", total: " + playersSynced); if (numberOfPlayers != playersSynced) { Debug.Log ("number of players != playersSynced! numplayers: " + numberOfPlayers + ", playersSynced: " + playersSynced); } } else { Debug.LogError ("recieved message for sync: " + arg2.payload + "; on state: " + sessionSyncPosition); StartCoroutine (callUpdateSessionStatus (sessionSyncPosition.ToString ())); } } else { Debug.LogError ("this message is not directed at us, senderID: " + arg2.sender_id + ", receiverID: '" + arg2.receiver_id + "', our clientID: '" + clientID + "'"); } }