示例#1
0
        protected void RequestGamebaseLogin(WebSocketRequest.RequestVO requestVO, int handle)
        {
            isAuthenticationAlreadyProgress = true;

            WebSocket.Instance.Request(requestVO, (response, error) =>
            {
                var callback = GamebaseCallbackHandler.GetCallback <GamebaseCallback.GamebaseDelegate <GamebaseResponse.Auth.AuthToken> >(handle);
                if (null == callback)
                {
                    return;
                }

                GamebaseCallbackHandler.UnregisterCallback(handle);

                if (null == error)
                {
                    var vo = JsonMapper.ToObject <AuthResponse.LoginInfo>(response);
                    if (true == vo.header.isSuccessful)
                    {
                        DataContainer.SetData(VOKey.Auth.LOGIN_INFO, vo);
                        Heartbeat.Instance.StartHeartbeat();
                    }
                    else
                    {
                        error = GamebaseErrorUtil.CreateGamebaseErrorByServerErrorCode(requestVO.transactionId, requestVO.apiId, vo.header, Domain);
                        if (null != vo.ban)
                        {
                            DataContainer.SetData(VOKey.Auth.BAN_INFO, vo.ban);

                            GamebaseSystemPopup.Instance.ShowErrorPopup(error, vo);
                        }
                    }
                }
                else
                {
                    GamebaseSystemPopup.Instance.ShowErrorPopup(error);
                }

                isAuthenticationAlreadyProgress = false;

                if (null == error)
                {
                    callback(JsonMapper.ToObject <GamebaseResponse.Auth.AuthToken>(response), error);
                }
                else
                {
                    callback(null, error);
                }
            });
        }
示例#2
0
        public virtual void Withdraw(int handle)
        {
            if (false == CanLogout(handle))
            {
                return;
            }

            var requestVO = AuthMessage.GetWithdrawMessage();

            WebSocket.Instance.Request(requestVO, (response, error) =>
            {
                var callback = GamebaseCallbackHandler.GetCallback <GamebaseCallback.ErrorDelegate>(handle);
                if (null == callback)
                {
                    return;
                }
                GamebaseCallbackHandler.UnregisterCallback(handle);

                if (null == error)
                {
                    var vo = JsonMapper.ToObject <AuthResponse.WithdrawInfo>(response);
                    if (true == vo.header.isSuccessful)
                    {
                        DataContainer.RemoveData(VOKey.Auth.LOGIN_INFO);
                        Heartbeat.Instance.StopHeartbeat();
                        AuthAdapterManager.Instance.IDPLogoutAll();
                        PurchaseAdapterManager.Instance.Destroy();
                    }
                    else
                    {
                        if (GamebaseServerErrorCode.MEMBER_ALREADY_WITHDRAWN == vo.header.resultCode)
                        {
                            DataContainer.RemoveData(VOKey.Auth.LOGIN_INFO);
                            Heartbeat.Instance.StopHeartbeat();
                        }
                        else
                        {
                            error = GamebaseErrorUtil.CreateGamebaseErrorByServerErrorCode(requestVO.transactionId, requestVO.apiId, vo.header, Domain);
                            GamebaseSystemPopup.Instance.ShowErrorPopup(error);
                        }
                    }
                }
                else
                {
                    GamebaseSystemPopup.Instance.ShowErrorPopup(error);
                }
                callback(error);
            });
        }
        public void GetLaunchingInfo(int handle)
        {
            requestVO.apiId = Lighthouse.API.Launching.ID.GET_LAUNCHING;
            WebSocket.Instance.Request(requestVO, (response, error) =>
            {
                if (null == error)
                {
                    var vo = JsonMapper.ToObject <LaunchingResponse.LaunchingInfo>(response);

                    if (true == vo.header.isSuccessful)
                    {
                        DataContainer.SetData(VOKey.Launching.LAUNCHING_INFO, vo);
                        Gamebase.SetDisplayLanguageCode(vo.request.displayLanguage);

                        GamebaseSystemPopup.Instance.ShowLaunchingPopup(vo);
                    }
                    else
                    {
                        error = GamebaseErrorUtil.CreateGamebaseErrorByServerErrorCode(requestVO.transactionId, requestVO.apiId, vo.header, Domain);

                        GamebaseSystemPopup.Instance.ShowErrorPopup(error);
                    }
                }
                else
                {
                    GamebaseSystemPopup.Instance.ShowErrorPopup(error);
                }

                var callback = GamebaseCallbackHandler.GetCallback <GamebaseCallback.GamebaseDelegate <GamebaseResponse.Launching.LaunchingInfo> >(handle);
                if (null == callback)
                {
                    return;
                }

                if (null == error)
                {
                    GamebaseUnitySDK.IsInitialized = true;
                    callback(JsonMapper.ToObject <GamebaseResponse.Launching.LaunchingInfo>(response), error);
                    ExecuteSchedule();
                }
                else
                {
                    callback(null, error);
                }
            });
        }