public override void Logout(int handle)
        {
            if (false == GamebaseUnitySDK.UseWebview)
            {
                base.Logout(handle);
                return;
            }

            if (false == CanLogout(handle))
            {
                return;
            }

            var requestVO = AuthMessage.GetLogoutMessage();

            WebSocket.Instance.Request(requestVO, (response, error) =>
            {
                GamebaseSystemPopup.Instance.ShowErrorPopup(error);

                var callback = GamebaseCallbackHandler.GetCallback <GamebaseCallback.ErrorDelegate>(handle);

                if (null == callback)
                {
                    return;
                }

                GamebaseCallbackHandler.UnregisterCallback(handle);

                DataContainer.RemoveData(VOKey.Auth.LOGIN_INFO);
                Heartbeat.Instance.StopHeartbeat();

                callback(null);
            });
        }
Beispiel #2
0
        public virtual void Logout(int handle)
        {
            if (false == CanLogout(handle))
            {
                return;
            }

            var requestVO = AuthMessage.GetLogoutMessage();

            WebSocket.Instance.Request(requestVO, (response, error) =>
            {
                GamebaseSystemPopup.Instance.ShowErrorPopup(error);

                var callback = GamebaseCallbackHandler.GetCallback <GamebaseCallback.ErrorDelegate>(handle);
                if (null == callback)
                {
                    return;
                }

                GamebaseCallbackHandler.UnregisterCallback(handle);
                #region error
                //if (error == null)
                //{
                //    var vo = JsonMapper.ToObject<AuthResponse.LogoutInfo>(response);
                //    if (vo.header.isSuccessful)
                //        DataContainer.RemoveData(VOKey.Auth.LOGIN_INFO);
                //    else
                //        error = GamebaseErrorUtil.CreateGamebaseErrorByServerErrorCode(requestVO.apiId, vo.header.resultCode, Domain, vo.header.resultMessage);
                //}

                //callback(error);
                #endregion

                // Regardless of the error, it is considered a success.
                DataContainer.RemoveData(VOKey.Auth.LOGIN_INFO);
                callback(null);

                Heartbeat.Instance.StopHeartbeat();
                AuthAdapterManager.Instance.IDPLogoutAll();
                PurchaseAdapterManager.Instance.Destroy();
            });
        }
Beispiel #3
0
        public void Logout(int handle)
        {
            GamebaseCallback.ErrorDelegate logoutCallback = (error) =>
            {
                if (Gamebase.IsSuccess(error) == true)
                {
                    GamebaseIndicatorReport.SendIndicatorData(
                        GamebaseIndicatorReportType.LogType.AUTH,
                        GamebaseIndicatorReportType.StabilityCode.GB_AUTH_LOGOUT_SUCCESS,
                        GamebaseIndicatorReportType.LogLevel.INFO,
                        new Dictionary <string, string>()
                    {
                        { GamebaseIndicatorReportType.AdditionalKey.GB_SUB_CATEGORY1, GamebaseIndicatorReportType.SubCategory.LOGOUT }
                    });
                }
                else
                {
                    GamebaseIndicatorReport.SendIndicatorData(
                        GamebaseIndicatorReportType.LogType.AUTH,
                        GamebaseIndicatorReportType.StabilityCode.GB_AUTH_LOGOUT_FAILED,
                        GamebaseIndicatorReportType.LogLevel.ERROR,
                        new Dictionary <string, string>()
                    {
                        { GamebaseIndicatorReportType.AdditionalKey.GB_SUB_CATEGORY1, GamebaseIndicatorReportType.SubCategory.LOGOUT }
                    },
                        error);
                }

                var callback = GamebaseCallbackHandler.GetCallback <GamebaseCallback.ErrorDelegate>(handle);

                if (callback != null)
                {
                    callback(null);
                }

                GamebaseCallbackHandler.UnregisterCallback(handle);
            };

            int logoutHandle = GamebaseCallbackHandler.RegisterCallback(logoutCallback);

            if (CanLogout(logoutHandle) == false)
            {
                return;
            }

            var requestVO = AuthMessage.GetLogoutMessage();

            WebSocket.Instance.Request(requestVO, (response, error) =>
            {
                GamebaseAnalytics.Instance.IdPCode = string.Empty;

                GamebaseSystemPopup.Instance.ShowErrorPopup(error);

                var callback = GamebaseCallbackHandler.GetCallback <GamebaseCallback.ErrorDelegate>(logoutHandle);
                if (callback == null)
                {
                    return;
                }

                GamebaseCallbackHandler.UnregisterCallback(logoutHandle);

                RemoveLoginData();

                callback(error);
            });
        }