private void OnAchievementsLoaded(int statusCode, AndroidJavaObject buffer) { if (this.mAuthState == AndroidClient.AuthState.LoadingAchs) { Logger.d("AUTH: Initial achievement load finished."); if (statusCode == 0 || statusCode == 3 || statusCode == 5) { Logger.d("Processing achievement buffer."); this.mAchievementBank.ProcessBuffer(buffer); Logger.d("Closing achievement buffer."); buffer.Call("close", new object[0]); Logger.d("AUTH: Auth process complete!"); this.mAuthState = AndroidClient.AuthState.Done; this.InvokeAuthCallback(true); this.CheckForConnectionExtras(); this.mRtmpClient.OnSignInSucceeded(); this.mTbmpClient.OnSignInSucceeded(); } else { Logger.w("AUTH: Failed to load achievements, status code " + statusCode); this.mAuthState = AndroidClient.AuthState.NoAuth; this.InvokeAuthCallback(false); } } else { Logger.w("OnAchievementsLoaded called unexpectedly in auth state " + this.mAuthState); } }
private void DoInitialAchievementLoad() { Logger.d("AUTH: Now performing initial achievement load..."); this.mAuthState = AndroidClient.AuthState.LoadingAchs; this.mGHManager.CallGmsApiWithResult("games.Games", "Achievements", "load", new AndroidClient.OnAchievementsLoadedResultProxy(this), new object[] { false }); Logger.d("AUTH: Initial achievement load call made."); }
public void SignOut() { Logger.d("AndroidClient.SignOut"); this.mSignOutInProgress = true; this.RunWhenConnectionStable(delegate { Logger.d("Calling GHM.SignOut"); this.mGHManager.SignOut(); this.mAuthState = AndroidClient.AuthState.NoAuth; this.mSignOutInProgress = false; Logger.d("Now signed out."); MsgHandler.Handle("ShowPlatformLogin", new object[0]); }); }
public void Authenticate(Action <bool> callback, bool silent) { if (this.mAuthState != AndroidClient.AuthState.NoAuth) { Logger.w("Authenticate() called while an authentication process was active. " + this.mAuthState); this.mAuthCallback = callback; return; } Logger.d("Making sure PlayGamesHelperObject is ready."); PlayGamesHelperObject.CreateObject(); Logger.d("PlayGamesHelperObject created."); this.mSilentAuth = silent; Logger.d("AUTH: starting auth process, silent=" + this.mSilentAuth); this.RunOnUiThread(delegate { GameHelperManager.ConnectionState state = this.mGHManager.State; if (state != GameHelperManager.ConnectionState.Connecting) { if (state != GameHelperManager.ConnectionState.Connected) { this.mAuthCallback = callback; if (this.mSilentAuth) { Logger.d("AUTH: not connected and silent=true, so failing."); this.mAuthState = AndroidClient.AuthState.NoAuth; this.InvokeAuthCallback(false); } else { Logger.d("AUTH: not connected and silent=false, so starting flow."); this.mAuthState = AndroidClient.AuthState.InProgress; this.mGHManager.BeginUserInitiatedSignIn(); } } else { Logger.d("AUTH: already connected! Proceeding to achievement load phase."); this.mAuthCallback = callback; this.DoInitialAchievementLoad(); } } else { Logger.d("AUTH: connection in progress; auth now pending."); this.mAuthCallback = callback; this.mAuthState = AndroidClient.AuthState.AuthPending; } }); }
internal void OnSignInFailed() { Logger.d("AndroidClient got OnSignInFailed."); if (this.mAuthState == AndroidClient.AuthState.AuthPending) { if (this.mSilentAuth) { Logger.d("AUTH: Auth flow was pending, but silent=true, so failing."); this.mAuthState = AndroidClient.AuthState.NoAuth; this.InvokeAuthCallback(false); } else { Logger.d("AUTH: Auth flow was pending and silent=false, so doing noisy auth."); this.mAuthState = AndroidClient.AuthState.InProgress; this.mGHManager.BeginUserInitiatedSignIn(); } } else if (this.mAuthState == AndroidClient.AuthState.InProgress) { Logger.d("AUTH: FAILED!"); this.mAuthState = AndroidClient.AuthState.NoAuth; this.InvokeAuthCallback(false); } else if (this.mAuthState == AndroidClient.AuthState.LoadingAchs) { Logger.d("AUTH: FAILED (while loading achievements)."); this.mAuthState = AndroidClient.AuthState.NoAuth; this.InvokeAuthCallback(false); } else if (this.mAuthState == AndroidClient.AuthState.NoAuth) { Logger.d("Normal OnSignInFailed received."); } else if (this.mAuthState == AndroidClient.AuthState.Done) { Logger.e("Authentication has been lost!"); this.mAuthState = AndroidClient.AuthState.NoAuth; } }