Esempio n. 1
0
    internal static void InternalSendReliableMessageCallback(Status.MultiplayerStatus response,
        IntPtr data) {
        Logger.d("Entering internal callback for InternalSendReliableMessageCallback " + response);

        Action<Status.MultiplayerStatus> callback =
            Callbacks.IntPtrToTempCallback<Action<Status.MultiplayerStatus>>(data);

        if (callback == null) {
            return;
        }

        try {
            callback(response);
        } catch (Exception e) {
            Logger.e("Error encountered executing InternalSendReliableMessageCallback. " +
                "Smothering to avoid passing exception into Native: " + e);
        }
    }
Esempio n. 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;
                            InvokeCallbackOnGameThread(silentCallbacks, false);
                            if (mPendingAuthCallbacks != null) {
                                GameServices().StartAuthorizationUI();
                            }
                        } else {
                            // Noisy sign-in failed - report failure.
                            Action<bool> localCallbacks = mPendingAuthCallbacks;
                            mPendingAuthCallbacks = null;
                            InvokeCallbackOnGameThread(localCallbacks, false);
                        }
                    }
                    break;
                case Types.AuthOperation.SIGN_OUT:
                    mAuthState = AuthState.Unauthenticated;
                    break;
                default:
                    Logger.e("Unknown AuthOperation " + operation);
                    break;
            }
        }
    }