Esempio n. 1
0
        public void QueryTransferAccount(int handle)
        {
            var callback = GamebaseCallbackHandler.GetCallback <GamebaseCallback.GamebaseDelegate <GamebaseResponse.Auth.TransferAccountInfo> >(handle);

            GamebaseErrorNotifier.FireNotSupportedAPI(this, callback);
            GamebaseCallbackHandler.UnregisterCallback(handle);
        }
        public override void ShowWebView(string url, GamebaseRequest.Webview.GamebaseWebViewConfiguration configuration = null, int closeCallbackHandle = -1, List <string> schemeList = null, int schemeEventHandle = -1)
        {
            GamebaseCallback.ErrorDelegate closeCallback = null;
            if (-1 != closeCallbackHandle)
            {
                closeCallback = GamebaseCallbackHandler.GetCallback <GamebaseCallback.ErrorDelegate>(closeCallbackHandle);
                GamebaseCallbackHandler.UnregisterCallback(closeCallbackHandle);
            }

            GamebaseCallback.GamebaseDelegate <string> schemeEvent = null;
            if (-1 != schemeEventHandle)
            {
                schemeEvent = GamebaseCallbackHandler.GetCallback <GamebaseCallback.GamebaseDelegate <string> >(schemeEventHandle);
                GamebaseCallbackHandler.UnregisterCallback(schemeEventHandle);
            }

            bool hasAdapter = WebviewAdapterManager.Instance.CreateWebviewAdapter("standalonewebviewadapter");

            if (false == hasAdapter)
            {
                GamebaseLog.Warn(GamebaseStrings.WEBVIEW_ADAPTER_NOT_FOUND, this);
                if (null != closeCallback)
                {
                    closeCallback(new GamebaseError(GamebaseErrorCode.WEBVIEW_UNKNOWN_ERROR, message: GamebaseStrings.WEBVIEW_ADAPTER_NOT_FOUND));
                }

                return;
            }

            WebviewAdapterManager.Instance.ShowWebView(url, configuration, closeCallback, schemeList, schemeEvent);
        }
Esempio n. 3
0
        public void TransferAccountWithIdPLogin(string accountId, string accountPassword, int handle)
        {
            var callback = GamebaseCallbackHandler.GetCallback <GamebaseCallback.GamebaseDelegate <GamebaseResponse.Auth.AuthToken> >(handle);

            GamebaseErrorNotifier.FireNotSupportedAPI(this, callback);
            GamebaseCallbackHandler.UnregisterCallback(handle);
        }
Esempio n. 4
0
        private void LoginWithCredentialInfo(Dictionary <string, object> credentialInfo, int handle)
        {
            if (false == CanLogin(handle))
            {
                return;
            }

            if (null == credentialInfo ||
                false == credentialInfo.ContainsKey(GamebaseAuthProviderCredential.PROVIDER_NAME) ||
                (false == credentialInfo.ContainsKey(GamebaseAuthProviderCredential.ACCESS_TOKEN) && false == credentialInfo.ContainsKey(GamebaseAuthProviderCredential.AUTHORIZATION_CODE)))
            {
                var callback = GamebaseCallbackHandler.GetCallback <GamebaseCallback.GamebaseDelegate <GamebaseResponse.Auth.AuthToken> >(handle);
                callback(null, new GamebaseError(GamebaseErrorCode.AUTH_IDP_LOGIN_INVALID_IDP_INFO, Domain));
                GamebaseCallbackHandler.UnregisterCallback(handle);
                return;
            }

            var providerName = (string)credentialInfo[GamebaseAuthProviderCredential.PROVIDER_NAME];
            var accessToken  = string.Empty;
            var authCode     = string.Empty;

            if (true == credentialInfo.ContainsKey(GamebaseAuthProviderCredential.ACCESS_TOKEN))
            {
                accessToken = (string)credentialInfo[GamebaseAuthProviderCredential.ACCESS_TOKEN];
            }

            if (true == credentialInfo.ContainsKey(GamebaseAuthProviderCredential.AUTHORIZATION_CODE))
            {
                authCode = (string)credentialInfo[GamebaseAuthProviderCredential.AUTHORIZATION_CODE];
            }

            var requestVO = AuthMessage.GetIDPLoginMessage(providerName, accessToken, authCode);

            RequestGamebaseLogin(requestVO, handle);
        }
Esempio n. 5
0
        private IEnumerator Init()
        {
            yield return(DisplayLanguage.Instance.DisplayLanguageInitialize());

            WebSocket.Instance.Initialize();
            yield return(GamebaseCoroutineManager.StartCoroutine(GamebaseGameObjectManager.GameObjectType.CORE_TYPE, WebSocket.Instance.Connect((error) =>
            {
                GamebaseSystemPopup.Instance.ShowErrorPopup(error);

                if (error == null)
                {
                    GamebaseLaunchingImplementation.Instance.RequestLaunchingInfo(initializeHandle);
                    return;
                }

                var callback = GamebaseCallbackHandler.GetCallback <GamebaseCallback.GamebaseDelegate <GamebaseResponse.Launching.LaunchingInfo> >(initializeHandle);

                if (callback != null)
                {
                    error.domain = Domain;
                    callback(null, error);
                }

                GamebaseCallbackHandler.UnregisterCallback(initializeHandle);
                initializeHandle = -1;
            })));
        }
Esempio n. 6
0
        public void AddMappingForcibly(string providerName, string forcingMappingKey, Dictionary <string, object> additionalInfo, int handle)
        {
            var callback = GamebaseCallbackHandler.GetCallback <GamebaseCallback.GamebaseDelegate <GamebaseResponse.Auth.AuthToken> >(handle);

            GamebaseErrorNotifier.FireNotSupportedAPI(this, callback, "AddMapping(additionalInfo)");
            GamebaseCallbackHandler.UnregisterCallback(handle);
        }
Esempio n. 7
0
        public void RemoveMapping(string providerName, int handle)
        {
            var callback = GamebaseCallbackHandler.GetCallback <GamebaseCallback.GamebaseDelegate <GamebaseResponse.Auth.AuthToken> >(handle);

            GamebaseErrorNotifier.FireNotSupportedAPI(this, callback);
            GamebaseCallbackHandler.UnregisterCallback(handle);
        }
Esempio n. 8
0
        public void LoginForLastLoggedInProvider(int handle)
        {
            var callback = GamebaseCallbackHandler.GetCallback <GamebaseCallback.GamebaseDelegate <GamebaseResponse.Auth.AuthToken> >(handle);

            GamebaseErrorNotifier.FireNotSupportedAPI(this, callback);
            GamebaseCallbackHandler.UnregisterCallback(handle);
        }
Esempio n. 9
0
        public void AddMapping(Dictionary <string, object> credentialInfo, int handle)
        {
            var callback = GamebaseCallbackHandler.GetCallback <GamebaseCallback.GamebaseDelegate <GamebaseResponse.Auth.AuthToken> >(handle);

            GamebaseErrorNotifier.FireNotSupportedAPI(this, callback, "AddMapping(credentialInfo)");
            GamebaseCallbackHandler.UnregisterCallback(handle);
        }
        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);
            });
        }
Esempio n. 11
0
        private void LoginFailedCallback(int handle)
        {
            var callback = GamebaseCallbackHandler.GetCallback <GamebaseCallback.GamebaseDelegate <GamebaseResponse.Auth.AuthToken> >(handle);

            GamebaseCallbackHandler.UnregisterCallback(handle);
            callback(null, new GamebaseError(GamebaseErrorCode.AUTH_IDP_LOGIN_FAILED));
        }
Esempio n. 12
0
        public void RenewTransferAccount(GamebaseRequest.Auth.TransferAccountRenewConfiguration configuration, int handle)
        {
            var callback = GamebaseCallbackHandler.GetCallback <GamebaseCallback.GamebaseDelegate <GamebaseResponse.Auth.TransferAccountInfo> >(handle);

            GamebaseErrorNotifier.FireNotSupportedAPI(this, callback);
            GamebaseCallbackHandler.UnregisterCallback(handle);
        }
Esempio n. 13
0
 virtual protected void OnCloseCallback(NativeMessage message)
 {
     if (false == string.IsNullOrEmpty(message.extraData))
     {
         int schemeEventHandle = int.Parse(message.extraData);
         GamebaseCallbackHandler.UnregisterCallback(schemeEventHandle);
     }
 }
Esempio n. 14
0
        protected bool CanLogin(int handle)
        {
            var callback = GamebaseCallbackHandler.GetCallback <GamebaseCallback.GamebaseDelegate <GamebaseResponse.Auth.AuthToken> >(handle);

            if (true == GamebaseUnitySDK.IsInitialized)
            {
                if (false == CommonGamebaseLaunching.IsPlayable())
                {
                    if (null == callback)
                    {
                        GamebaseLog.Warn(GamebaseStrings.AUTH_NOT_PLAYABLE, this);
                        return(false);
                    }
                    GamebaseCallbackHandler.UnregisterCallback(handle);
                    callback(null, new GamebaseError(GamebaseErrorCode.AUTH_NOT_PLAYABLE, Domain));
                    return(false);
                }
            }
            else
            {
                if (null == callback)
                {
                    GamebaseLog.Warn(GamebaseStrings.NOT_INITIALIZED, this);
                    return(false);
                }
                GamebaseCallbackHandler.UnregisterCallback(handle);
                callback(null, new GamebaseError(GamebaseErrorCode.NOT_INITIALIZED, Domain));
                return(false);
            }

            if (true == string.IsNullOrEmpty(Gamebase.GetUserID()))
            {
                if (false == isAuthenticationAlreadyProgress)
                {
                    return(true);
                }
                else
                {
                    if (null == callback)
                    {
                        GamebaseLog.Warn(GamebaseStrings.AUTH_ALREADY_IN_PROGRESS_ERROR, this);
                        return(false);
                    }
                    GamebaseCallbackHandler.UnregisterCallback(handle);
                    callback(null, new GamebaseError(GamebaseErrorCode.AUTH_ALREADY_IN_PROGRESS_ERROR, Domain));
                    return(false);
                }
            }

            if (null == callback)
            {
                return(false);
            }

            GamebaseCallbackHandler.UnregisterCallback(handle);
            callback(null, new GamebaseError(GamebaseErrorCode.AUTH_IDP_LOGIN_FAILED, Domain, GamebaseStrings.ALREADY_LOGGED_IN));
            return(false);
        }
Esempio n. 15
0
        public void Login(Dictionary <string, object> credentialInfo, int handle)
        {
            CheckLaunchingStatusExpire(() =>
            {
                GamebaseCallback.GamebaseDelegate <GamebaseResponse.Auth.AuthToken> providerLoginCallback = (authToken, error) =>
                {
                    string providerName = string.Empty;
                    if (credentialInfo.ContainsKey(GamebaseAuthProviderCredential.PROVIDER_NAME) == true)
                    {
                        providerName = (string)credentialInfo[GamebaseAuthProviderCredential.PROVIDER_NAME];
                    }

                    if (Gamebase.IsSuccess(error) == true)
                    {
                        GamebaseIndicatorReport.SetLastLoggedInInfo(providerName, authToken.member.userId);
                        GamebaseIndicatorReport.SendIndicatorData(
                            GamebaseIndicatorReportType.LogType.AUTH,
                            GamebaseIndicatorReportType.StabilityCode.GB_AUTH_LOGIN_SUCCESS,
                            GamebaseIndicatorReportType.LogLevel.INFO,
                            new Dictionary <string, string>()
                        {
                            { GamebaseIndicatorReportType.AdditionalKey.GB_SUB_CATEGORY1, GamebaseIndicatorReportType.SubCategory.LOGIN },
                            { GamebaseIndicatorReportType.AdditionalKey.GB_LOGIN_IDP, providerName },
                            { GamebaseIndicatorReportType.AdditionalKey.GB_CREDENTIAL, JsonMapper.ToJson(credentialInfo) }
                        });
                    }
                    else
                    {
                        GamebaseIndicatorReport.SendIndicatorData(
                            GamebaseIndicatorReportType.LogType.AUTH,
                            GamebaseIndicatorReportType.StabilityCode.GB_AUTH_LOGIN_CANCELED,
                            GamebaseIndicatorReportType.LogLevel.DEBUG,
                            new Dictionary <string, string>()
                        {
                            { GamebaseIndicatorReportType.AdditionalKey.GB_SUB_CATEGORY1, GamebaseIndicatorReportType.SubCategory.LOGIN },
                            { GamebaseIndicatorReportType.AdditionalKey.GB_LOGIN_IDP, providerName },
                            { GamebaseIndicatorReportType.AdditionalKey.GB_CREDENTIAL, JsonMapper.ToJson(credentialInfo) }
                        },
                            error,
                            true);
                    }

                    var callback = GamebaseCallbackHandler.GetCallback <GamebaseCallback.GamebaseDelegate <GamebaseResponse.Auth.AuthToken> >(handle);

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

                    GamebaseCallbackHandler.UnregisterCallback(handle);
                };

                int providerLoginHandle = GamebaseCallbackHandler.RegisterCallback(providerLoginCallback);

                LoginWithCredentialInfo(credentialInfo, providerLoginHandle);
            });
        }
Esempio n. 16
0
        private void LoginWithProviderName(string providerName, int handle)
        {
            if (false == AuthAdapterManager.Instance.IsSupportedIDP(providerName))
            {
                var callback = GamebaseCallbackHandler.GetCallback <GamebaseCallback.GamebaseDelegate <GamebaseResponse.Auth.AuthToken> >(handle);
                GamebaseErrorNotifier.FireNotSupportedAPI(
                    this,
                    callback,
                    string.Format("Login({0})", providerName));
                GamebaseCallbackHandler.UnregisterCallback(handle);
                return;
            }

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

            if (GamebaseAuthProvider.GUEST == providerName)
            {
                var requestVO = AuthMessage.GetIDPLoginMessage(providerName);
                RequestGamebaseLogin(requestVO, handle);

                return;
            }

            bool hasAdapter = AuthAdapterManager.Instance.CreateIDPAdapter(providerName);

            if (false == hasAdapter)
            {
                var callback = GamebaseCallbackHandler.GetCallback <GamebaseCallback.GamebaseDelegate <GamebaseResponse.Auth.AuthToken> >(handle);
                callback(null, new GamebaseError(GamebaseErrorCode.AUTH_IDP_LOGIN_FAILED, message: GamebaseStrings.AUTH_ADAPTER_NOT_FOUND_NEED_SETUP));
                GamebaseCallbackHandler.UnregisterCallback(handle);
            }

            AuthAdapterManager.Instance.IDPLogin((adapterError) =>
            {
                if (Gamebase.IsSuccess(adapterError))
                {
                    var IDPAccessToken = AuthAdapterManager.Instance.GetIDPData <string>(providerName, AuthAdapterManager.MethodName.GET_IDP_ACCESS_TOKEN);
                    var requestVO      = AuthMessage.GetIDPLoginMessage(providerName, IDPAccessToken);
                    RequestGamebaseLogin(requestVO, handle);

                    return;
                }

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

                GamebaseCallbackHandler.UnregisterCallback(handle);
                callback(null, new GamebaseError(GamebaseErrorCode.AUTH_IDP_LOGIN_FAILED, Domain, error: adapterError));
                AuthAdapterManager.Instance.IDPLogout(providerName);
            });
        }
Esempio n. 17
0
        public void RequestTransfer(string transferKey, int handle)
        {
            var callback = GamebaseCallbackHandler.GetCallback <GamebaseCallback.GamebaseDelegate <GamebaseResponse.Auth.AuthToken> >(handle);

            GamebaseErrorNotifier.FireNotSupportedAPI(
                this,
                "RequestTransfer",
                callback);
            GamebaseCallbackHandler.UnregisterCallback(handle);
        }
Esempio n. 18
0
        public virtual void Login(string providerName, Dictionary <string, object> additionalInfo, int handle)
        {
            var callback = GamebaseCallbackHandler.GetCallback <GamebaseCallback.GamebaseDelegate <GamebaseResponse.Auth.AuthToken> >(handle);

            GamebaseErrorNotifier.FireNotSupportedAPI(
                this,
                "Login(additionalInfo)",
                callback);
            GamebaseCallbackHandler.UnregisterCallback(handle);
        }
Esempio n. 19
0
        public void IssueTransferKey(long expiresIn, int handle)
        {
            var callback = GamebaseCallbackHandler.GetCallback <GamebaseCallback.GamebaseDelegate <GamebaseResponse.Auth.TransferKeyInfo> >(handle);

            GamebaseErrorNotifier.FireNotSupportedAPI(
                this,
                "IssueTransferKey",
                callback);
            GamebaseCallbackHandler.UnregisterCallback(handle);
        }
Esempio n. 20
0
        private void LoginWithProviderName(string providerName, int handle)
        {
            if (GamebaseUnitySDK.UseWebViewLogin == false)
            {
                base.Login(providerName, handle);
                return;
            }

            if (IsSupportedIDPByWebview(providerName) == false)
            {
                base.Login(providerName, handle);
                return;
            }

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

            if (providerName.Equals(GamebaseAuthProvider.GUEST, StringComparison.Ordinal) == true)
            {
                var requestVO = AuthMessage.GetIDPLoginMessage(providerName);
                RequestGamebaseLogin(requestVO, handle);
                return;
            }

            bool hasAdapter = WebviewAdapterManager.Instance.CreateWebviewAdapter("standalonewebviewadapter");

            if (hasAdapter == false)
            {
                var callback = GamebaseCallbackHandler.GetCallback <GamebaseCallback.GamebaseDelegate <GamebaseResponse.Auth.AuthToken> >(handle);
                GamebaseCallbackHandler.UnregisterCallback(handle);
                callback(null, new GamebaseError(GamebaseErrorCode.AUTH_IDP_LOGIN_FAILED, message: GamebaseStrings.WEBVIEW_ADAPTER_NOT_FOUND));
                return;
            }

            isAuthenticationAlreadyProgress = true;

            GetAccessToken(providerName, (requestVO) =>
            {
                if (requestVO == null)
                {
                    isAuthenticationAlreadyProgress = false;
                    LoginFailedCallback(handle);
                    return;
                }

                RequestGamebaseLogin(requestVO, handle);
            });
        }
Esempio n. 21
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);
                }
            });
        }
Esempio n. 22
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);
            });
        }
Esempio n. 23
0
        public virtual void Login(string providerName, int handle)
        {
            CheckLaunchingStatusExpire(() =>
            {
                GamebaseCallback.GamebaseDelegate <GamebaseResponse.Auth.AuthToken> providerLoginCallback = (authToken, error) =>
                {
                    if (Gamebase.IsSuccess(error) == true)
                    {
                        GamebaseIndicatorReport.SetLastLoggedInInfo(providerName, authToken.member.userId);
                        GamebaseIndicatorReport.SendIndicatorData(
                            GamebaseIndicatorReportType.LogType.AUTH,
                            GamebaseIndicatorReportType.StabilityCode.GB_AUTH_LOGIN_SUCCESS,
                            GamebaseIndicatorReportType.LogLevel.INFO,
                            new Dictionary <string, string>()
                        {
                            { GamebaseIndicatorReportType.AdditionalKey.GB_SUB_CATEGORY1, GamebaseIndicatorReportType.SubCategory.LOGIN },
                            { GamebaseIndicatorReportType.AdditionalKey.GB_LOGIN_IDP, providerName }
                        });
                    }
                    else
                    {
                        GamebaseIndicatorReport.SendIndicatorData(
                            GamebaseIndicatorReportType.LogType.AUTH,
                            GamebaseIndicatorReportType.StabilityCode.GB_AUTH_LOGIN_CANCELED,
                            GamebaseIndicatorReportType.LogLevel.DEBUG,
                            new Dictionary <string, string>()
                        {
                            { GamebaseIndicatorReportType.AdditionalKey.GB_SUB_CATEGORY1, GamebaseIndicatorReportType.SubCategory.LOGIN },
                            { GamebaseIndicatorReportType.AdditionalKey.GB_LOGIN_IDP, providerName }
                        },
                            error,
                            true);
                    }

                    var callback = GamebaseCallbackHandler.GetCallback <GamebaseCallback.GamebaseDelegate <GamebaseResponse.Auth.AuthToken> >(handle);

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

                    GamebaseCallbackHandler.UnregisterCallback(handle);
                };

                int providerLoginHandle = GamebaseCallbackHandler.RegisterCallback(providerLoginCallback);

                LoginWithProviderName(providerName, providerLoginHandle);
            });
        }
Esempio n. 24
0
        protected bool CanLogout(int handle)
        {
            if (true == string.IsNullOrEmpty(Gamebase.GetUserID()))
            {
                var callback = GamebaseCallbackHandler.GetCallback <GamebaseCallback.ErrorDelegate>(handle);
                if (null == callback)
                {
                    return(false);
                }
                GamebaseCallbackHandler.UnregisterCallback(handle);
                callback(new GamebaseError(GamebaseErrorCode.NOT_LOGGED_IN, Domain));
                return(false);
            }

            return(true);
        }
Esempio n. 25
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);
                }
            });
        }
Esempio n. 26
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();
            });
        }
Esempio n. 27
0
        public void Initialize(GamebaseRequest.GamebaseConfiguration configuration, int handle)
        {
            if (initializeHandle != -1)
            {
                GamebaseCallbackHandler.UnregisterCallback(initializeHandle);
            }

            GamebaseCallback.GamebaseDelegate <GamebaseResponse.Launching.LaunchingInfo> initializeCallback = (launchingInfo, error) =>
            {
                GamebaseResponse.Launching.LaunchingInfo.GamebaseLaunching.TCGBClient.Stability stability = null;
                if (error == null || error.code == GamebaseErrorCode.SUCCESS)
                {
                    #region Iap Setting
                    GamebaseLog.Debug("ToastSdk Initialize", this);
                    ToastSdk.Initialize();

                    if (PurchaseAdapterManager.Instance.CreateIDPAdapter("iapadapter") == true)
                    {
                        var iapConfiguration = new GamebaseRequest.Purchase.Configuration();
                        iapConfiguration.appKey    = launchingInfo.tcProduct.iap.appKey;
                        iapConfiguration.storeCode = configuration.storeCode;
                        PurchaseAdapterManager.Instance.SetConfiguration(iapConfiguration);
                    }

                    stability = launchingInfo.launching.tcgbClient.stability;
                    #endregion
                }

                GamebaseIndicatorReport.Initialize(
                    stability,
                    () => {
                    if (Gamebase.IsSuccess(error) == false)
                    {
                        initializeFailCount++;
                        if (initializeFailCount > GamebaseIndicatorReport.stability.initFailCount)
                        {
                            GamebaseIndicatorReport.SendIndicatorData(
                                GamebaseIndicatorReportType.LogType.INIT,
                                GamebaseIndicatorReportType.StabilityCode.GB_INIT_FAILED_MULTIPLE_TIMES,
                                GamebaseIndicatorReportType.LogLevel.WARN,
                                new Dictionary <string, string>()
                            {
                                { GamebaseIndicatorReportType.AdditionalKey.GB_CONFIGURATION, JsonMapper.ToJson(configuration) }
                            });
                            initializeFailCount = 0;
                        }
                    }
                    else
                    {
                        initializeFailCount = 0;
                    }

                    var callback = GamebaseCallbackHandler.GetCallback <GamebaseCallback.GamebaseDelegate <GamebaseResponse.Launching.LaunchingInfo> >(handle);

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

                    GamebaseCallbackHandler.UnregisterCallback(handle);
                });
            };

            initializeHandle = GamebaseCallbackHandler.RegisterCallback(initializeCallback);
            GamebaseCoroutineManager.StartCoroutine(GamebaseGameObjectManager.GameObjectType.CORE_TYPE, Init());
        }
Esempio n. 28
0
        public void Login(string providerName, Dictionary <string, object> additionalInfo, int handle)
        {
            GamebaseCallback.GamebaseDelegate <GamebaseResponse.Auth.AuthToken> providerLoginCallback = (authToken, error) =>
            {
                if (Gamebase.IsSuccess(error) == true)
                {
                    GamebaseIndicatorReport.SetLastLoggedInInfo(providerName, authToken.member.userId);
                    GamebaseIndicatorReport.SendIndicatorData(
                        GamebaseIndicatorReportType.LogType.AUTH,
                        GamebaseIndicatorReportType.StabilityCode.GB_AUTH_LOGIN_SUCCESS,
                        GamebaseIndicatorReportType.LogLevel.INFO,
                        new Dictionary <string, string>()
                    {
                        { GamebaseIndicatorReportType.AdditionalKey.GB_SUB_CATEGORY1, GamebaseIndicatorReportType.SubCategory.LOGIN },
                        { GamebaseIndicatorReportType.AdditionalKey.GB_LOGIN_IDP, providerName },
                        { GamebaseIndicatorReportType.AdditionalKey.GB_CREDENTIAL, JsonMapper.ToJson(additionalInfo) }
                    });
                }
                else
                {
                    GamebaseIndicatorReport.SendIndicatorData(
                        GamebaseIndicatorReportType.LogType.AUTH,
                        GamebaseIndicatorReportType.StabilityCode.GB_AUTH_LOGIN_CANCELED,
                        GamebaseIndicatorReportType.LogLevel.DEBUG,
                        new Dictionary <string, string>()
                    {
                        { GamebaseIndicatorReportType.AdditionalKey.GB_SUB_CATEGORY1, GamebaseIndicatorReportType.SubCategory.LOGIN },
                        { GamebaseIndicatorReportType.AdditionalKey.GB_LOGIN_IDP, providerName },
                        { GamebaseIndicatorReportType.AdditionalKey.GB_CREDENTIAL, JsonMapper.ToJson(additionalInfo) }
                    },
                        error,
                        true);
                }

                var callback = GamebaseCallbackHandler.GetCallback <GamebaseCallback.GamebaseDelegate <GamebaseResponse.Auth.AuthToken> >(handle);

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

                GamebaseCallbackHandler.UnregisterCallback(handle);
            };

            int providerLoginHandle = GamebaseCallbackHandler.RegisterCallback(providerLoginCallback);

            if (AuthAdapterManager.Instance.IsSupportedIDP(providerName) == false)
            {
                var callback = GamebaseCallbackHandler.GetCallback <GamebaseCallback.GamebaseDelegate <GamebaseResponse.Auth.AuthToken> >(providerLoginHandle);
                GamebaseErrorNotifier.FireNotSupportedAPI(
                    this,
                    callback,
                    string.Format("LoginWithAdditionalInfo({0})", providerName));
                GamebaseCallbackHandler.UnregisterCallback(providerLoginHandle);
                return;
            }

            if (CanLogin(providerLoginHandle) == false)
            {
                return;
            }

            bool hasAdapter = AuthAdapterManager.Instance.CreateIDPAdapter(providerName);

            if (hasAdapter == false)
            {
                var callback = GamebaseCallbackHandler.GetCallback <GamebaseCallback.GamebaseDelegate <GamebaseResponse.Auth.AuthToken> >(providerLoginHandle);
                callback(null, new GamebaseError(GamebaseErrorCode.AUTH_IDP_LOGIN_FAILED, message: GamebaseStrings.AUTH_ADAPTER_NOT_FOUND_NEED_SETUP));
                GamebaseCallbackHandler.UnregisterCallback(providerLoginHandle);
            }

            AuthAdapterManager.Instance.IDPLogin(additionalInfo, (adapterError) =>
            {
                if (Gamebase.IsSuccess(adapterError) == true)
                {
                    var idPAccessToken = AuthAdapterManager.Instance.GetIDPData <string>(providerName, AuthAdapterManager.MethodName.GET_IDP_ACCESS_TOKEN);
                    var requestVO      = AuthMessage.GetIDPLoginMessage(providerName, idPAccessToken);
                    RequestGamebaseLogin(requestVO, providerLoginHandle);

                    return;
                }

                var callback = GamebaseCallbackHandler.GetCallback <GamebaseCallback.GamebaseDelegate <GamebaseResponse.Auth.AuthToken> >(providerLoginHandle);
                if (callback == null)
                {
                    return;
                }

                GamebaseCallbackHandler.UnregisterCallback(providerLoginHandle);
                callback(null, new GamebaseError(GamebaseErrorCode.AUTH_IDP_LOGIN_FAILED, Domain, error: adapterError));
                AuthAdapterManager.Instance.IDPLogout(providerName);
            });
        }
Esempio n. 29
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);
                }
            });
        }
Esempio n. 30
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);
            });
        }