internal static UIStatus ConvertUIStatus(Status.UIStatus status)
 {
     switch (status)
     {
         case Status.UIStatus.VALID:
             return UIStatus.Valid;
         case Status.UIStatus.ERROR_INTERNAL:
             return UIStatus.InternalError;
         case Status.UIStatus.ERROR_NOT_AUTHORIZED:
             return UIStatus.NotAuthorized;
         case Status.UIStatus.ERROR_TIMEOUT:
             return UIStatus.Timeout;
         case Status.UIStatus.ERROR_VERSION_UPDATE_REQUIRED:
             return UIStatus.VersionUpdateRequired;
         case Status.UIStatus.ERROR_CANCELED:
             return UIStatus.UserClosedUI;
         case Status.UIStatus.ERROR_UI_BUSY:
             return UIStatus.UiBusy;
         default:
             throw new InvalidOperationException("Unknown status: " + status);
     }
 }
 internal static ResponseStatus ConvertResponseStatus(Status.ResponseStatus status)
 {
     switch (status)
     {
         case Status.ResponseStatus.VALID:
             return ResponseStatus.Success;
         case Status.ResponseStatus.VALID_BUT_STALE:
             return ResponseStatus.SuccessWithStale;
         case Status.ResponseStatus.ERROR_INTERNAL:
             return ResponseStatus.InternalError;
         case Status.ResponseStatus.ERROR_LICENSE_CHECK_FAILED:
             return ResponseStatus.LicenseCheckFailed;
         case Status.ResponseStatus.ERROR_NOT_AUTHORIZED:
             return ResponseStatus.NotAuthorized;
         case Status.ResponseStatus.ERROR_TIMEOUT:
             return ResponseStatus.Timeout;
         case Status.ResponseStatus.ERROR_VERSION_UPDATE_REQUIRED:
             return ResponseStatus.VersionUpdateRequired;
         default:
             throw new InvalidOperationException("Unknown status: " + status);
     }
 }
예제 #3
0
        internal static void InternalLeaveRoomCallback(Status.ResponseStatus response, IntPtr data)
        {
            GooglePlayGames.OurUtils.Logger.d("Entering internal callback for InternalLeaveRoomCallback");

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

            if (callback == null)
            {
                return;
            }

            try
            {
                callback(response);
            }
            catch (Exception e)
            {
                GooglePlayGames.OurUtils.Logger.e("Error encountered executing InternalLeaveRoomCallback. " +
                    "Smothering to avoid passing exception into Native: " + e);
            }
        }
 internal static CommonStatusCodes ConvertResponseStatusToCommonStatus(Status.ResponseStatus status)
 {
     switch (status) {
     case Status.ResponseStatus.VALID:
         return CommonStatusCodes.Success;
     case Status.ResponseStatus.VALID_BUT_STALE:
         return CommonStatusCodes.SuccessCached;
     case Status.ResponseStatus.ERROR_INTERNAL:
         return CommonStatusCodes.InternalError;
     case Status.ResponseStatus.ERROR_LICENSE_CHECK_FAILED:
         return CommonStatusCodes.LicenseCheckFailed;
     case Status.ResponseStatus.ERROR_NOT_AUTHORIZED:
         return CommonStatusCodes.AuthApiAccessForbidden;
     case Status.ResponseStatus.ERROR_TIMEOUT:
         return CommonStatusCodes.Timeout;
     case Status.ResponseStatus.ERROR_VERSION_UPDATE_REQUIRED:
         return CommonStatusCodes.ServiceVersionUpdateRequired;
     default:
         Debug.LogWarning("Unknown ResponseStatus: " + status +
             ", defaulting to CommonStatusCodes.Error");
         return CommonStatusCodes.Error;
     }
 }
예제 #5
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;
            }
        }
    }
예제 #6
0
 private static QuestUiResult UiErrorToQuestUiResult(Status.UIStatus status)
 {
     switch (status)
     {
         case Status.UIStatus.ERROR_INTERNAL:
             return QuestUiResult.InternalError;
         case Status.UIStatus.ERROR_NOT_AUTHORIZED:
             return QuestUiResult.NotAuthorized;
         case Status.UIStatus.ERROR_CANCELED:
             return QuestUiResult.UserCanceled;
         case Status.UIStatus.ERROR_VERSION_UPDATE_REQUIRED:
             return QuestUiResult.VersionUpdateRequired;
         case Status.UIStatus.ERROR_TIMEOUT:
             return QuestUiResult.Timeout;
         case Status.UIStatus.ERROR_UI_BUSY:
             return QuestUiResult.UiBusy;
         default:
             GooglePlayGames.OurUtils.Logger.e("Unknown error status: " + status);
             return QuestUiResult.InternalError;
     }
 }
예제 #7
0
 private static QuestClaimMilestoneStatus FromClaimStatus(
     Status.QuestClaimMilestoneStatus status)
 {
     switch (status)
     {
         case Status.QuestClaimMilestoneStatus.VALID:
             return QuestClaimMilestoneStatus.Success;
         case Status.QuestClaimMilestoneStatus.ERROR_INTERNAL:
             return QuestClaimMilestoneStatus.InternalError;
         case Status.QuestClaimMilestoneStatus.ERROR_MILESTONE_ALREADY_CLAIMED:
             return QuestClaimMilestoneStatus.MilestoneAlreadyClaimed;
         case Status.QuestClaimMilestoneStatus.ERROR_MILESTONE_CLAIM_FAILED:
             return QuestClaimMilestoneStatus.MilestoneClaimFailed;
         case Status.QuestClaimMilestoneStatus.ERROR_NOT_AUTHORIZED:
             return QuestClaimMilestoneStatus.NotAuthorized;
         case Status.QuestClaimMilestoneStatus.ERROR_TIMEOUT:
             return QuestClaimMilestoneStatus.Timeout;
         default:
             GooglePlayGames.OurUtils.Logger.e("Encountered unknown status: " + status);
             return QuestClaimMilestoneStatus.InternalError;
     }
 }
예제 #8
0
 private static QuestAcceptStatus FromAcceptStatus(Status.QuestAcceptStatus status)
 {
     switch (status)
     {
         case Status.QuestAcceptStatus.ERROR_INTERNAL:
             return QuestAcceptStatus.InternalError;
         case Status.QuestAcceptStatus.ERROR_NOT_AUTHORIZED:
             return QuestAcceptStatus.NotAuthorized;
         case Status.QuestAcceptStatus.ERROR_QUEST_NOT_STARTED:
             return QuestAcceptStatus.QuestNotStarted;
         case Status.QuestAcceptStatus.ERROR_QUEST_NO_LONGER_AVAILABLE:
             return QuestAcceptStatus.QuestNoLongerAvailable;
         case Status.QuestAcceptStatus.ERROR_TIMEOUT:
             return QuestAcceptStatus.Timeout;
         case Status.QuestAcceptStatus.VALID:
             return QuestAcceptStatus.Success;
         default:
             GooglePlayGames.OurUtils.Logger.e("Encountered unknown status: " + status);
             return QuestAcceptStatus.InternalError;
     }
 }
예제 #9
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);
        }
    }