Ejemplo n.º 1
0
        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 (vo.header.isSuccessful == true)
                    {
                        DataContainer.SetData(VOKey.Launching.LAUNCHING_INFO, vo);
                        Gamebase.SetDisplayLanguageCode(vo.request.displayLanguage);

                        GamebaseSystemPopup.Instance.ShowLaunchingPopup(vo);

                        Introspect.Instance.SetInterval(vo.launching.standalone.introspectionInterval);
                    }
                    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);
                }
            });
        }
Ejemplo n.º 2
0
        public void IssueShortTermTicket(int handle)
        {
            if (string.IsNullOrEmpty(Gamebase.GetUserID()) == true)
            {
                GamebaseLog.Warn("Not LoggedIn", this, "CompletePurchase");
                return;
            }

            GamebaseLog.Debug("Start", this, "IssueShortTermTicket");

            byte[] bytesForEncoding = Encoding.UTF8.GetBytes(ISSUE_SHORT_TERM_TICKET_PURPOSE);
            string encodedString    = Convert.ToBase64String(bytesForEncoding);

            var requestVO = AuthMessage.GetIssueShortTermTicketMessage(encodedString, ISSUE_SHORT_TERM_TICKET_EXPIRESIN);

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

                GamebaseCallbackHandler.UnregisterCallback(handle);

                if (error == null)
                {
                    var vo = JsonMapper.ToObject <AuthResponse.IssueShortTermTicketInfo>(response);
                    if (vo.header.isSuccessful == true)
                    {
                    }
                    else
                    {
                        error = GamebaseErrorUtil.CreateGamebaseErrorByServerErrorCode(requestVO.transactionId, requestVO.apiId, vo.header, Domain);
                    }

                    callback(vo.ticket, error);
                }
                else
                {
                    callback(null, error);
                }
            });
        }
Ejemplo n.º 3
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)
                {
                    AuthRequest.LoginVO.Payload payload = JsonMapper.ToObject <AuthRequest.LoginVO.Payload>(requestVO.payload);
                    GamebaseAnalytics.Instance.IdPCode  = payload.idPInfo.idPCode;

                    var vo = JsonMapper.ToObject <AuthResponse.LoginInfo>(response);
                    if (true == vo.header.isSuccessful)
                    {
                        DataContainer.SetData(VOKey.Auth.LOGIN_INFO, vo);
                        Heartbeat.Instance.StartHeartbeat();
                        Introspect.Instance.StartIntrospect();
                    }
                    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 (error == null)
                {
                    GamebaseLog.Debug("ToastSdk UserId", this);
                    GamebaseResponse.Auth.AuthToken authToken = JsonMapper.ToObject <GamebaseResponse.Auth.AuthToken>(response);
                    ToastSdk.UserId = authToken.member.userId;
                    AuthRequest.LoginVO.Payload payload = JsonMapper.ToObject <AuthRequest.LoginVO.Payload>(requestVO.payload);
                    SetIapExtraData(payload.idPInfo.idPCode);
                    GamebaseLog.Debug("GamebaseIapManager Initialize", this);

                    PurchaseAdapterManager.Instance.Initialize();

                    callback(authToken, error);
                }
                else
                {
                    callback(null, error);
                }
            });
        }
Ejemplo n.º 4
0
        public void Withdraw(int handle)
        {
            GamebaseCallback.ErrorDelegate withdrawCallback = (error) =>
            {
                if (Gamebase.IsSuccess(error) == true)
                {
                    GamebaseIndicatorReport.SendIndicatorData(
                        GamebaseIndicatorReportType.LogType.AUTH,
                        GamebaseIndicatorReportType.StabilityCode.GB_AUTH_WITHDRAW_SUCCESS,
                        GamebaseIndicatorReportType.LogLevel.INFO,
                        new Dictionary <string, string>()
                    {
                        { GamebaseIndicatorReportType.AdditionalKey.GB_SUB_CATEGORY1, GamebaseIndicatorReportType.SubCategory.WITHDRAW }
                    });
                }
                else
                {
                    GamebaseIndicatorReport.SendIndicatorData(
                        GamebaseIndicatorReportType.LogType.AUTH,
                        GamebaseIndicatorReportType.StabilityCode.GB_AUTH_WITHDRAW_FAILED,
                        GamebaseIndicatorReportType.LogLevel.ERROR,
                        new Dictionary <string, string>()
                    {
                        { GamebaseIndicatorReportType.AdditionalKey.GB_SUB_CATEGORY1, GamebaseIndicatorReportType.SubCategory.WITHDRAW }
                    },
                        error);
                }

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

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

                GamebaseCallbackHandler.UnregisterCallback(handle);
            };


            int withdrawHandle = GamebaseCallbackHandler.RegisterCallback(withdrawCallback);

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

            var requestVO = AuthMessage.GetWithdrawMessage();

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

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

                if (error == null)
                {
                    var vo = JsonMapper.ToObject <AuthResponse.WithdrawInfo>(response);
                    if (vo.header.isSuccessful == true)
                    {
                        RemoveLoginData();
                    }
                    else
                    {
                        if (GamebaseServerErrorCode.MEMBER_ALREADY_WITHDRAWN == vo.header.resultCode)
                        {
                            RemoveLoginData();
                        }
                        else
                        {
                            error = GamebaseErrorUtil.CreateGamebaseErrorByServerErrorCode(requestVO.transactionId, requestVO.apiId, vo.header, Domain);
                            GamebaseSystemPopup.Instance.ShowErrorPopup(error);
                        }
                    }
                }
                else
                {
                    GamebaseSystemPopup.Instance.ShowErrorPopup(error);
                }
                callback(error);
            });
        }