private void PopulateUser(uint authGeneration, GooglePlayGames.Native.PInvoke.PlayerManager.FetchSelfResponse response) { Logger.d("Populating User"); if (authGeneration != mAuthGeneration) { Logger.d("Received user callback after signout occurred, ignoring"); } else { lock (AuthStateLock) { if (response.Status() != CommonErrorStatus.ResponseStatus.VALID && response.Status() != CommonErrorStatus.ResponseStatus.VALID_BUT_STALE) { Logger.e("Error retrieving user, signing out"); Action <bool, string> action = mPendingAuthCallbacks; mPendingAuthCallbacks = null; if (action != null) { InvokeCallbackOnGameThread(action, false, "Cannot load user profile"); } SignOut(); return; } mUser = response.Self().AsPlayer(); mFriends = null; } Logger.d("Found User: "******"Maybe finish for User"); MaybeFinishAuthentication(); } }
private void PopulateUser(uint authGeneration, GooglePlayGames.Native.PInvoke.PlayerManager.FetchSelfResponse response) { Logger.d("Populating User"); if ((int)authGeneration != (int)this.mAuthGeneration) { Logger.d("Received user callback after signout occurred, ignoring"); } else { lock (this.AuthStateLock) { if (response.Status() != CommonErrorStatus.ResponseStatus.VALID && response.Status() != CommonErrorStatus.ResponseStatus.VALID_BUT_STALE) { Logger.e("Error retrieving user, signing out"); Action <bool> pendingAuthCallbacks = this.mPendingAuthCallbacks; this.mPendingAuthCallbacks = (Action <bool>)null; if (pendingAuthCallbacks != null) { NativeClient.InvokeCallbackOnGameThread <bool>(pendingAuthCallbacks, false); } this.SignOut(); return; } this.mUser = response.Self().AsPlayer(); this.mFriends = (List <GooglePlayGames.BasicApi.Multiplayer.Player>)null; } Logger.d("Found User: "******"Maybe finish for User"); this.MaybeFinishAuthentication(); } }
public static Participant ConvertParticipant(AndroidJavaObject participant) { string displayName = participant.Call <string>("getDisplayName"); string participantId = participant.Call <string>("getParticipantId"); Participant.ParticipantStatus status = Participant.ParticipantStatus.Unknown; GooglePlayGames.BasicApi.Multiplayer.Player player = null; bool connected = participant.Call <bool>("isConnectedToRoom"); int statusValue = participant.Call <int>("getStatus"); switch (statusValue) { case JavaConsts.STATUS_NOT_INVITED_YET: status = Participant.ParticipantStatus.NotInvitedYet; break; case JavaConsts.STATUS_INVITED: status = Participant.ParticipantStatus.Invited; break; case JavaConsts.STATUS_JOINED: status = Participant.ParticipantStatus.Joined; break; case JavaConsts.STATUS_DECLINED: status = Participant.ParticipantStatus.Declined; break; case JavaConsts.STATUS_LEFT: status = Participant.ParticipantStatus.Left; break; case JavaConsts.STATUS_FINISHED: status = Participant.ParticipantStatus.Finished; break; case JavaConsts.STATUS_UNRESPONSIVE: status = Participant.ParticipantStatus.Unresponsive; break; default: status = Participant.ParticipantStatus.Unknown; break; } AndroidJavaObject playerObj = JavaUtil.CallNullSafeObjectMethod(participant, "getPlayer"); if (playerObj != null) { player = new GooglePlayGames.BasicApi.Multiplayer.Player(playerObj.Call <string>("getDisplayName"), playerObj.Call <string>("getPlayerId")); playerObj.Dispose(); playerObj = null; } return(new Participant(displayName, participantId, status, player, connected)); }
private void ToUnauthenticated() { lock (this.AuthStateLock) { this.mUser = (GooglePlayGames.BasicApi.Multiplayer.Player)null; this.mFriends = (List <GooglePlayGames.BasicApi.Multiplayer.Player>)null; this.mAchievements = (Dictionary <string, GooglePlayGames.BasicApi.Achievement>)null; this.mAuthState = NativeClient.AuthState.Unauthenticated; ++this.mAuthGeneration; } }
private void ToUnauthenticated() { lock (AuthStateLock) { mUser = null; mFriends = null; mAchievements = null; mAuthState = AuthState.Unauthenticated; mTokenClient = clientImpl.CreateTokenClient(true); mAuthGeneration++; } }
private void ToUnauthenticated() { lock (AuthStateLock) { mUser = null; mAchievements = null; mAuthState = AuthState.Unauthenticated; mAuthGeneration++; } }
void PopulateUser(uint authGeneration, PlayerManager.FetchSelfResponse response) { Logger.d("Populating User"); if (authGeneration != mAuthGeneration) { Logger.d("Received user callback after signout occurred, ignoring"); return; } lock (AuthStateLock) { if (response.Status() != Status.ResponseStatus.VALID && response.Status() != Status.ResponseStatus.VALID_BUT_STALE) { Logger.e("Error retrieving user, signing out"); var localCallbacks = mPendingAuthCallbacks; mPendingAuthCallbacks = null; if (localCallbacks != null) { InvokeCallbackOnGameThread(localCallbacks, false); } SignOut(); return; } mUser = response.Self().AsPlayer(); } Logger.d("Found User: "******"Maybe finish for User"); MaybeFinishAuthentication(); }
private static TurnBasedMatch GetMatchFromJsonString(string matchAsJson) { Dictionary<string, object> parsedMatch = Json.Deserialize(matchAsJson) as Dictionary<string, object>; // Let's create our participant list List<Participant> participantList = new List<Participant>(); List<object> parsedParticipants = parsedMatch["participants"] as List<object>; foreach (Dictionary<string, object> nextParticipant in parsedParticipants) { Dictionary<string, object> playerRepresentation = nextParticipant["player"] as Dictionary<string, object>; Player participantAsPlayer = new Player((string)playerRepresentation["playerDisplayName"], (string)playerRepresentation["playerId"]); Participant participant = new Participant((string)nextParticipant["displayName"], (string)nextParticipant["participantId"], convertIntFromiOSToParticipantStatus(Convert.ToInt32((System.Int64)nextParticipant["status"])), participantAsPlayer, (bool)nextParticipant["isConnectedToRoom"]); participantList.Add(participant); Debug.Log("Adding participant " + participant.ToString()); } string matchData = (string)parsedMatch["matchData"]; byte[] bytes; if (matchData == null) { Debug.Log ("Got a null matchData."); bytes = null; } else { bytes = System.Convert.FromBase64String(matchData); } TurnBasedMatch matchCreated = new TurnBasedMatch((string)parsedMatch["matchId"], bytes, (bool)parsedMatch["canRematch"], (string)parsedMatch["localParticipantId"], participantList, Convert.ToInt32((System.Int64)parsedMatch["availableAutomatchSlots"]), (string)parsedMatch["pendingParticipantId"], convertIntoFromiOSToMatchTurnStatus(Convert.ToInt32((System.Int64)parsedMatch["turnStatus"])), convertIntoFromiOSToMatchStatus(Convert.ToInt32((System.Int64)parsedMatch["matchStatus"])), Convert.ToInt32((System.Int64)parsedMatch["variant"])); Debug.Log("Final parsed match object is " + matchCreated.ToString()); return matchCreated; }
private static void RtmpParticipantListChangedCallback(string jsonifiedParticipants) { mAllParticipants = new Dictionary<string, Participant>(); Logger.d("IOSRtmpClient.ParticipantListChanged, JSONString=" + jsonifiedParticipants); Dictionary<string, Participant> connectedInThisUpdate = new Dictionary<string, Participant>(); var myArray = Json.Deserialize(jsonifiedParticipants) as List<object>; foreach (Dictionary<string, object> nextData in myArray) { Player dummyPlayer = new Player((string)nextData["playerName"], (string)nextData["playerId"]); Participant nextParticipant = new Participant((string)nextData["displayName"], (string)nextData["participantId"], convertIntFromiOSToParticipantStatus((System.Int64)nextData["status"]), dummyPlayer, (System.Int64)nextData["connectedToRoom"] == 1); Debug.Log("Participant " + nextParticipant.DisplayName + " id " + nextParticipant.ParticipantId + " status " + nextParticipant.Status + " isConnected " + nextParticipant.IsConnectedToRoom); mAllParticipants.Add(nextParticipant.ParticipantId, nextParticipant); if (nextParticipant.IsConnectedToRoom) { connectedInThisUpdate.Add(nextParticipant.ParticipantId, nextParticipant); } } string[] newlyConnected; string[] newlyDisconnected; newlyConnected = SubtractParticipants(connectedInThisUpdate, mConnectedParticipants); newlyDisconnected = SubtractParticipants(mConnectedParticipants, connectedInThisUpdate); foreach (string newlyConnectedId in newlyConnected) { Logger.d(newlyConnectedId + " just connected."); } foreach (string newlyDisonnectedId in newlyDisconnected) { Logger.d(newlyDisonnectedId + " just disconnected."); } mConnectedParticipants = connectedInThisUpdate; Logger.d("UpdateRoom: participant list now has " + mConnectedParticipants.Count + " participants."); if (sDeliveredRoomConnected) { if (newlyConnected.Length > 0 && sRtmpListener != null) { Logger.d("UpdateRoom: calling OnPeersConnected callback"); sRtmpListener.OnPeersConnected(newlyConnected); } if (newlyDisconnected.Length > 0 && sRtmpListener != null) { Logger.d("UpdateRoom: calling OnPeersDisconnected callback"); sRtmpListener.OnPeersDisconnected(newlyDisconnected); } } }
public static Participant ConvertParticipant(AndroidJavaObject participant) { string displayName = participant.Call<string>("getDisplayName"); string participantId = participant.Call<string>("getParticipantId"); Participant.ParticipantStatus status = Participant.ParticipantStatus.Unknown; Player player = null; bool connected = participant.Call<bool>("isConnectedToRoom"); int statusValue = participant.Call<int>("getStatus"); switch (statusValue) { case JavaConsts.STATUS_NOT_INVITED_YET: status = Participant.ParticipantStatus.NotInvitedYet; break; case JavaConsts.STATUS_INVITED: status = Participant.ParticipantStatus.Invited; break; case JavaConsts.STATUS_JOINED: status = Participant.ParticipantStatus.Joined; break; case JavaConsts.STATUS_DECLINED: status = Participant.ParticipantStatus.Declined; break; case JavaConsts.STATUS_LEFT: status = Participant.ParticipantStatus.Left; break; case JavaConsts.STATUS_FINISHED: status = Participant.ParticipantStatus.Finished; break; case JavaConsts.STATUS_UNRESPONSIVE: status = Participant.ParticipantStatus.Unresponsive; break; default: status = Participant.ParticipantStatus.Unknown; break; } AndroidJavaObject playerObj = JavaUtil.CallNullSafeObjectMethod(participant, "getPlayer"); if (playerObj != null) { player = new Player(playerObj.Call<string>("getDisplayName"), playerObj.Call<string>("getPlayerId")); playerObj.Dispose(); playerObj = null; } return new Participant(displayName, participantId, status, player, connected); }