コード例 #1
0
ファイル: NativeClient.cs プロジェクト: zunaalabaya/TAC-BOT
 public void Authenticate(Action <bool> callback, bool silent)
 {
     lock (this.AuthStateLock)
     {
         if (this.mAuthState == NativeClient.AuthState.Authenticated)
         {
             NativeClient.InvokeCallbackOnGameThread <bool>(callback, true);
             return;
         }
         if (this.mSilentAuthFailed && silent)
         {
             NativeClient.InvokeCallbackOnGameThread <bool>(callback, false);
             return;
         }
         if (callback != null)
         {
             if (silent)
             {
                 this.mSilentAuthCallbacks += callback;
             }
             else
             {
                 this.mPendingAuthCallbacks += callback;
             }
         }
     }
     this.InitializeGameServices();
     if (silent)
     {
         return;
     }
     this.GameServices().StartAuthorizationUI();
 }
コード例 #2
0
ファイル: NativeClient.cs プロジェクト: zunaalabaya/TAC-BOT
        private void HandleAuthTransition(Types.AuthOperation operation, CommonErrorStatus.AuthStatus status)
        {
            Logger.d("Starting Auth Transition. Op: " + (object)operation + " status: " + (object)status);
            lock (this.AuthStateLock)
            {
                switch (operation)
                {
                case Types.AuthOperation.SIGN_IN:
                    if (status == CommonErrorStatus.AuthStatus.VALID)
                    {
                        // ISSUE: object of a compiler-generated type is created
                        // ISSUE: variable of a compiler-generated type
                        NativeClient.\u003CHandleAuthTransition\u003Ec__AnonStorey10E transitionCAnonStorey10E = new NativeClient.\u003CHandleAuthTransition\u003Ec__AnonStorey10E();
                        // ISSUE: reference to a compiler-generated field
                        transitionCAnonStorey10E.\u003C\u003Ef__this = this;
                        if (this.mSilentAuthCallbacks != null)
                        {
                            this.mPendingAuthCallbacks += this.mSilentAuthCallbacks;
                            this.mSilentAuthCallbacks   = (Action <bool>)null;
                        }
                        // ISSUE: reference to a compiler-generated field
                        transitionCAnonStorey10E.currentAuthGeneration = this.mAuthGeneration;
                        // ISSUE: reference to a compiler-generated method
                        this.mServices.AchievementManager().FetchAll(new Action <GooglePlayGames.Native.PInvoke.AchievementManager.FetchAllResponse>(transitionCAnonStorey10E.\u003C\u003Em__20));
                        // ISSUE: reference to a compiler-generated method
                        this.mServices.PlayerManager().FetchSelf(new Action <GooglePlayGames.Native.PInvoke.PlayerManager.FetchSelfResponse>(transitionCAnonStorey10E.\u003C\u003Em__21));
                        break;
                    }
                    if (this.mAuthState == NativeClient.AuthState.SilentPending)
                    {
                        this.mSilentAuthFailed = true;
                        this.mAuthState        = NativeClient.AuthState.Unauthenticated;
                        Action <bool> silentAuthCallbacks = this.mSilentAuthCallbacks;
                        this.mSilentAuthCallbacks = (Action <bool>)null;
                        Debug.Log((object)"Invoking callbacks, AuthState changed from silentPending to Unauthenticated.");
                        NativeClient.InvokeCallbackOnGameThread <bool>(silentAuthCallbacks, false);
                        if (this.mPendingAuthCallbacks == null)
                        {
                            break;
                        }
                        Debug.Log((object)"there are pending auth callbacks - starting AuthUI");
                        this.GameServices().StartAuthorizationUI();
                        break;
                    }
                    Debug.Log((object)("AuthState == " + (object)this.mAuthState + " calling auth callbacks with failure"));
                    Action <bool> pendingAuthCallbacks = this.mPendingAuthCallbacks;
                    this.mPendingAuthCallbacks = (Action <bool>)null;
                    NativeClient.InvokeCallbackOnGameThread <bool>(pendingAuthCallbacks, false);
                    break;

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

                default:
                    Logger.e("Unknown AuthOperation " + (object)operation);
                    break;
                }
            }
        }
コード例 #3
0
ファイル: NativeClient.cs プロジェクト: zunaalabaya/TAC-BOT
 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();
     }
 }
コード例 #4
0
ファイル: NativeClient.cs プロジェクト: zunaalabaya/TAC-BOT
 private static Action <T> AsOnGameThreadCallback <T>(Action <T> callback)
 {
     if (callback == null)
     {
         return((Action <T>)(_param0 => {}));
     }
     return((Action <T>)(result => NativeClient.InvokeCallbackOnGameThread <T>(callback, result)));
 }
コード例 #5
0
 private static Action <T> AsOnGameThreadCallback <T>(Action <T> callback)
 {
     if (callback == null)
     {
         return(delegate
         {
         });
     }
     return(delegate(T result)
     {
         NativeClient.InvokeCallbackOnGameThread <T>(callback, result);
     });
 }
コード例 #6
0
ファイル: NativeClient.cs プロジェクト: zunaalabaya/TAC-BOT
        private void MaybeFinishAuthentication()
        {
            Action <bool> callback = (Action <bool>)null;

            lock (this.AuthStateLock)
            {
                if (this.mUser == null || this.mAchievements == null)
                {
                    Logger.d("Auth not finished. User="******" achievements=" + (object)this.mAchievements);
                    return;
                }
                Logger.d("Auth finished. Proceeding.");
                callback = this.mPendingAuthCallbacks;
                this.mPendingAuthCallbacks = (Action <bool>)null;
                this.mAuthState            = NativeClient.AuthState.Authenticated;
            }
            if (callback == null)
            {
                return;
            }
            Logger.d("Invoking Callbacks: " + (object)callback);
            NativeClient.InvokeCallbackOnGameThread <bool>(callback, true);
        }
コード例 #7
0
ファイル: NativeClient.cs プロジェクト: zunaalabaya/TAC-BOT
 private void PopulateAchievements(uint authGeneration, GooglePlayGames.Native.PInvoke.AchievementManager.FetchAllResponse response)
 {
     if ((int)authGeneration != (int)this.mAuthGeneration)
     {
         Logger.d("Received achievement callback after signout occurred, ignoring");
     }
     else
     {
         Logger.d("Populating Achievements, status = " + (object)response.Status());
         lock (this.AuthStateLock)
         {
             if (response.Status() != CommonErrorStatus.ResponseStatus.VALID && response.Status() != CommonErrorStatus.ResponseStatus.VALID_BUT_STALE)
             {
                 Logger.e("Error retrieving achievements - check the log for more information. Failing signin.");
                 Action <bool> pendingAuthCallbacks = this.mPendingAuthCallbacks;
                 this.mPendingAuthCallbacks = (Action <bool>)null;
                 if (pendingAuthCallbacks != null)
                 {
                     NativeClient.InvokeCallbackOnGameThread <bool>(pendingAuthCallbacks, false);
                 }
                 this.SignOut();
                 return;
             }
             Dictionary <string, GooglePlayGames.BasicApi.Achievement> dictionary = new Dictionary <string, GooglePlayGames.BasicApi.Achievement>();
             foreach (NativeAchievement nativeAchievement in response)
             {
                 using (nativeAchievement)
                     dictionary[nativeAchievement.Id()] = nativeAchievement.AsAchievement();
             }
             Logger.d("Found " + (object)dictionary.Count + " Achievements");
             this.mAchievements = dictionary;
         }
         Logger.d("Maybe finish for Achievements");
         this.MaybeFinishAuthentication();
     }
 }