Beispiel #1
0
        private void HandleAuthTransition(Types.AuthOperation operation, Status.AuthStatus status)
        {
            GooglePlayGames.OurUtils.Logger.d("Starting Auth Transition. Op: " + operation + " status: " + status);
            lock (AuthStateLock)
            {
                switch (operation)
                {
                case Types.AuthOperation.SIGN_IN:
                    if (status == Status.AuthStatus.VALID)
                    {
                        uint currentAuthGeneration = mAuthGeneration;
                        mServices.AchievementManager().FetchAll(
                            results => PopulateAchievements(currentAuthGeneration, results));
                        mServices.PlayerManager().FetchSelf(
                            results => PopulateUser(currentAuthGeneration, results));
                    }
                    else
                    {
                        // Auth failed
                        // The initial silent auth failed - take note of that and
                        // notify any pending silent-auth callbacks. If there are
                        // additional non-silent auth callbacks pending, attempt to auth
                        // by popping the Auth UI.
                        mAuthState = AuthState.Unauthenticated;
                        GooglePlayGames.OurUtils.Logger.d(
                            "AuthState == " + mAuthState +
                            " calling auth callbacks with failure");

                        // Noisy sign-in failed - report failure.
                        Action <bool, string> localCallbacks = mPendingAuthCallbacks;
                        mPendingAuthCallbacks = null;
                        InvokeCallbackOnGameThread(localCallbacks, false, "Authentication failed");
                    }
                    break;

                case Types.AuthOperation.SIGN_OUT:
                    ToUnauthenticated();
                    break;

                default:
                    GooglePlayGames.OurUtils.Logger.e("Unknown AuthOperation " + operation);
                    break;
                }
            }
        }
Beispiel #2
0
        private void HandleAuthTransition(Types.AuthOperation operation, Status.AuthStatus status)
        {
            Logger.d("Starting Auth Transition. Op: " + operation + " status: " + status);
            lock (AuthStateLock)
            {
                switch (operation)
                {
                case Types.AuthOperation.SIGN_IN:
                    if (status == Status.AuthStatus.VALID)
                    {
                        // If sign-in succeeded, treat any silent auth callbacks the same way
                        // we would treat loud ones.
                        if (mSilentAuthCallbacks != null)
                        {
                            mPendingAuthCallbacks += mSilentAuthCallbacks;
                            mSilentAuthCallbacks   = null;
                        }

                        uint currentAuthGeneration = mAuthGeneration;
                        mServices.AchievementManager().FetchAll(
                            results => PopulateAchievements(currentAuthGeneration, results));
                        mServices.PlayerManager().FetchSelf(
                            results => PopulateUser(currentAuthGeneration, results));
                    }
                    else
                    {
                        // Auth failed
                        if (mAuthState == AuthState.SilentPending)
                        {
                            // The initial silent auth failed - take note of that and
                            // notify any pending silent-auth callbacks. If there are
                            // additional non-silent auth callbacks pending, attempt to auth
                            // by popping the Auth UI.
                            mSilentAuthFailed = true;
                            mAuthState        = AuthState.Unauthenticated;
                            var silentCallbacks = mSilentAuthCallbacks;
                            mSilentAuthCallbacks = null;
                            Debug.Log("Invoking callbacks, AuthState changed from silentPending to Unauthenticated.");

                            InvokeCallbackOnGameThread(silentCallbacks, false);
                            if (mPendingAuthCallbacks != null)
                            {
                                Debug.Log("there are pending auth callbacks - starting AuthUI");
                                GameServices().StartAuthorizationUI();
                            }
                        }
                        else
                        {
                            Debug.Log("AuthState == " + mAuthState + " calling auth callbacks with failure");
                            // Noisy sign-in failed - report failure.
                            Action <bool> localCallbacks = mPendingAuthCallbacks;
                            mPendingAuthCallbacks = null;
                            InvokeCallbackOnGameThread(localCallbacks, false);
                        }
                    }
                    break;

                case Types.AuthOperation.SIGN_OUT:
                    ToUnauthenticated();
                    break;

                default:
                    Logger.e("Unknown AuthOperation " + operation);
                    break;
                }
            }
        }