Exemple #1
0
        public static WebSocketRequest.RequestVO GetHeartbeatMessage()
        {
            var vo = new LaunchingRequest.HeartBeatVO();

            vo.parameter.appId           = GamebaseUnitySDK.AppID;
            vo.payload.appId             = GamebaseUnitySDK.AppID;
            vo.payload.clientVersion     = GamebaseUnitySDK.AppVersion;
            vo.payload.deviceCountryCode = GamebaseUnitySDK.CountryCode;
            vo.payload.osCode            = GamebaseUnitySDK.Platform;

            if (string.IsNullOrEmpty(Gamebase.GetUserID()))
            {
                vo.payload.userId = "0";
            }
            else
            {
                vo.payload.userId = Gamebase.GetUserID();
            }

            vo.payload.usimCountryCode = "ZZ";
            vo.payload.storeCode       = GamebaseUnitySDK.StoreCode;
            vo.payload.idpCode         = GamebaseAnalytics.Instance.IdPCode;
            vo.payload.deviceModel     = GamebaseUnitySDK.DeviceModel;


            var requestVO = new WebSocketRequest.RequestVO(Lighthouse.API.Presence.PRODUCT_ID, Lighthouse.API.VERSION, GamebaseUnitySDK.AppID);

            requestVO.apiId      = Lighthouse.API.Presence.ID.HEARTBEAT;
            requestVO.parameters = vo.parameter;
            requestVO.payload    = JsonMapper.ToJson(vo.payload);
            return(requestVO);
        }
Exemple #2
0
        public void ShowErrorPopup(GamebaseError error, BaseVO vo = null)
        {
            if (true == Gamebase.IsSuccess(error))
            {
                return;
            }

            GamebaseLog.Debug(
                string.Format("ErrorCode : {0}", error.code),
                this,
                "ShowErrorPopup");

            switch (error.code)
            {
            case GamebaseErrorCode.AUTH_BANNED_MEMBER:                  // 이용정지
            {
                ShowBanPopup((AuthResponse.LoginInfo)vo);
                break;
            }

            default:
            {
                break;
            }
            }
        }
        public void ShowHeartbeatErrorPopup(GamebaseError error)
        {
            if (true == Gamebase.IsSuccess(error))
            {
                return;
            }

            GamebaseLog.Debug(string.Format("ErrorCode : {0}", error.code), this);

            switch (error.code)
            {
            case GamebaseErrorCode.BANNED_MEMBER:                       // 이용정지 KickOut
            {
                ShowKickOutPopup();
                break;
            }

            case GamebaseErrorCode.INVALID_MEMBER:                      // 잘못된 사용자 KickOut
            {
                break;
            }

            default:
            {
                break;
            }
            }
        }
        private static void CreateBaseData()
        {
            basicDataDictionary = new Dictionary <string, string>()
            {
                { GB_PLATFORM, platform },
                { GB_PROJECT_APP_ID, GamebaseUnitySDK.AppID },
                { GB_APP_CLIENT_VERSION, GamebaseUnitySDK.AppVersion },
                { GB_LAUNCHING_ZONE, GamebaseUnitySDK.ZoneType.ToUpper() },
                { GB_UNITY_SDK_VERSION, Gamebase.GetSDKVersion() },
                { GB_SERVER_API_VERSION, Lighthouse.API.VERSION },
                { GB_LAST_LOGGEDIN_IDP, "" },
                { GB_LAST_LOGGEDIN_USER_ID, "" },
                { GB_GUEST_UUID, GamebaseUnitySDK.UUID },
                { GB_DEVICE_LANGUAGE_CODE, Gamebase.GetDeviceLanguageCode() },
                { GB_DISPLAY_LANGUAGE_CODE, Gamebase.GetDisplayLanguageCode() },
                { GB_COUNTRY_CODE_USIM, string.Empty },
                { GB_COUNTRY_CODE_DEVICE, Gamebase.GetCountryCodeOfDevice() },
                { GB_NETWORK_TYPE, Gamebase.Network.GetNetworkType().ToString().Replace("TYPE_", "") },
                { GB_GAME_ENGINE, GAME_ENGINE },
                { GB_CARRIER, "NONE" },
                { GB_DEVICE_MODEL, SystemInfo.deviceModel }
            };

            if (PlayerPrefs.HasKey(KEY_LAST_LOGGEDIN_IDP) == true)
            {
                string idPPreference = PlayerPrefs.GetString(KEY_LAST_LOGGEDIN_IDP);
                basicDataDictionary.Add(GB_LAST_LOGGEDIN_IDP, idPPreference);
            }

            if (PlayerPrefs.HasKey(KEY_LAST_LOGGEDIN_USERID) == true)
            {
                string userIdPreference = PlayerPrefs.GetString(KEY_LAST_LOGGEDIN_USERID);
                basicDataDictionary.Add(GB_LAST_LOGGEDIN_USER_ID, userIdPreference);
            }
        }
        public static WebSocketRequest.RequestVO GetLaunchingInfoMessage()
        {
            var vo = new LaunchingRequest.ReqLaunchingInfoVO();

            vo.parameter.appId = GamebaseUnitySDK.AppID;

            if (string.IsNullOrEmpty(Gamebase.GetUserID()))
            {
                vo.parameter.userId = "0";
            }
            else
            {
                vo.parameter.userId = Gamebase.GetUserID();
            }


            vo.parameter.clientVersion     = GamebaseUnitySDK.AppVersion;
            vo.parameter.sdkVersion        = GamebaseUnitySDK.SDKVersion;
            vo.parameter.uuid              = GamebaseUnitySDK.UUID;
            vo.parameter.deviceKey         = GamebaseUnitySDK.DeviceKey;
            vo.parameter.osCode            = GamebaseUnitySDK.Platform;
            vo.parameter.osVersion         = GamebaseUnitySDK.OsVersion;
            vo.parameter.deviceModel       = GamebaseUnitySDK.DeviceModel;
            vo.parameter.deviceLanguage    = GamebaseUnitySDK.Language;
            vo.parameter.displayLanguage   = GamebaseUnitySDK.DisplayLanguageCode;
            vo.parameter.deviceCountryCode = GamebaseUnitySDK.CountryCode;
            vo.parameter.usimCountryCode   = "ZZ";
            vo.parameter.lcnt              = 0;

            var requestVO = new WebSocketRequest.RequestVO(Lighthouse.API.Launching.PRODUCT_ID, Lighthouse.API.VERSION, GamebaseUnitySDK.AppID);

            requestVO.parameters = vo.parameter;
            return(requestVO);
        }
Exemple #6
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);
        }
Exemple #7
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);
            });
        }
        private bool IsLoggedin()
        {
            if (true == string.IsNullOrEmpty(Gamebase.GetUserID()))
            {
                return(false);
            }

            return(true);
        }
        virtual protected void InvokeCredentialInfoMethod(string providerName, int handle, string methodName, string forcingMappingKey = null)
        {
            bool hasAdapter = AuthAdapterManager.Instance.CreateIDPAdapter(providerName);

            if (hasAdapter == true)
            {
                AuthAdapterManager.Instance.GetIDPCredentialInfo(providerName, (credentialInfo, adapterError) =>
                {
                    if (Gamebase.IsSuccess(adapterError) == true)
                    {
                        GamebaseExtraDataHandler.RegisterExtraData(handle, providerName);

                        if (methodName.Equals("Login", StringComparison.Ordinal) == true)
                        {
                            Login(credentialInfo, handle);
                        }
                        else if (methodName.Equals("AddMapping", StringComparison.Ordinal) == true)
                        {
                            AddMapping(credentialInfo, handle);
                        }
                        else if (methodName.Equals("AddMappingForcibly", StringComparison.Ordinal) == true)
                        {
                            AddMappingForcibly(credentialInfo, forcingMappingKey, handle);
                        }
                    }
                    else
                    {
                        var callback = GamebaseCallbackHandler.GetCallback <GamebaseCallback.GamebaseDelegate <GamebaseResponse.Auth.AuthToken> >(handle);

                        if (callback == null)
                        {
                            return;
                        }

                        AuthAdapterManager.Instance.IDPLogout(providerName);
                        callback(null, new GamebaseError(GamebaseErrorCode.AUTH_IDP_LOGIN_FAILED, "AndroidGamebaseAuth", error: adapterError));
                    }
                });
            }
            else
            {
                GamebaseLog.Debug("Call native method", this);

                if (methodName.Equals("Login", StringComparison.Ordinal) == true)
                {
                    CallNativeLogin(providerName, handle);
                }
                else if (methodName.Equals("AddMapping", StringComparison.Ordinal) == true)
                {
                    CallNativeMapping(providerName, handle);
                }
                else if (methodName.Equals("AddMappingForcibly", StringComparison.Ordinal) == true)
                {
                    CallNativeMappingForcibly(providerName, forcingMappingKey, handle);
                }
            }
        }
        virtual protected void OnLogout(NativeMessage message)
        {
            GamebaseError error = message.GetGamebaseError();

            if (Gamebase.IsSuccess(error) == true)
            {
                AuthAdapterManager.Instance.IDPLogoutAll();
            }
        }
Exemple #11
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);
            });
        }
 public static void ShowWaterMark()
 {
     if (true == Gamebase.IsSandbox())
     {
         if (null == GamebaseUnitySDKSettings.GetComponent <GamebaseWaterMark>())
         {
             GamebaseUnitySDKSettings.AddComponent <GamebaseWaterMark>();
         }
     }
 }
 private GamebaseDebugSettings()
 {
     Gamebase.AddObserver((data) =>
     {
         if (data.type.Equals(GamebaseObserverType.LAUNCHING) == true)
         {
             var launchingInfo = Gamebase.Launching.GetLaunchingInformations();
             SetRemoteSettings(launchingInfo);
         }
     });
 }
        public void SetUserMeta(RequestType type)
        {
            if (string.IsNullOrEmpty(Gamebase.GetUserID()) == true)
            {
                GamebaseLog.Warn("Not LoggedIn", this, "SetUserMeta");
                return;
            }

            GamebaseLog.Debug(
                string.Format("SetUserMeta Type : {0}", type.ToString()),
                this,
                "SetUserMeta");

            AnalyticsRequest.UserMetaVO vo = new AnalyticsRequest.UserMetaVO();
            vo.payload.appId    = GamebaseUnitySDK.AppID;
            vo.parameter.userId = Gamebase.GetUserID();

            switch (type)
            {
            case RequestType.USER_DATA:
            {
                vo.payload.userMetaData = MakeUserMetaData();
                break;
            }

            case RequestType.LEVEL_UP:
            {
                vo.payload.userMetaData = MakeLevelUpData();
                break;
            }
            }

            var requestVO = new WebSocketRequest.RequestVO(PRODUCT_ID, Lighthouse.API.VERSION, GamebaseUnitySDK.AppID);

            requestVO.apiId      = ID.SET_USER_META;
            requestVO.payload    = JsonMapper.ToJson(vo.payload);
            requestVO.parameters = vo.parameter;

            WebSocket.Instance.Request(requestVO, (response, error) =>
            {
                if (Gamebase.IsSuccess(error) == false)
                {
                    GamebaseLog.Warn(
                        string.Format(
                            "{0}\n{1}",
                            "Failed request.",
                            GamebaseJsonUtil.ToPrettyJsonString(error)),
                        this,
                        "SetUserMeta");
                }
            });
        }
        virtual protected void OnRemoveMapping(NativeMessage message)
        {
            GamebaseError error = message.GetGamebaseError();

            string providerName = GamebaseExtraDataHandler.GetExtraData(message.handle);

            GamebaseExtraDataHandler.UnregisterExtraData(message.handle);

            if (Gamebase.IsSuccess(error) == true)
            {
                AuthAdapterManager.Instance.IDPLogout(providerName);
            }
        }
Exemple #16
0
        private void SetIapExtraData(string providerName)
        {
            GamebaseLog.Debug("SetIapExtraData", this);
            ToastSdk.UserId = Gamebase.GetUserID();

            var userId = Gamebase.GetAuthProviderUserID(providerName);

            PurchaseAdapterManager.Instance.SetExtraData(
                new Dictionary <string, string>()
            {
                { KEY_IAP_EXTRA_USER_ID, userId }
            });
        }
Exemple #17
0
            public RequestVO(
                string productId,
                string version,
                string appId)
            {
                this.productId = productId;
                this.version   = version;
                this.appId     = appId;

                transactionId = Lighthouse.CreateTransactionId().ToString().ToLower();
                headers       = new Dictionary <string, string>();
                headers.Add("X-TCGB-Transaction-Id", transactionId);
                headers.Add("X-TCGB-Access-Token", Gamebase.GetAccessToken());
            }
Exemple #18
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);
            });
        }
        public void LoginForLastLoggedInProvider(GamebaseCallback.GamebaseDelegate <GamebaseResponse.Auth.AuthToken> callback)
        {
            GamebaseCallback.GamebaseDelegate <GamebaseResponse.Auth.AuthToken> loginCallback = (authToken, error) =>
            {
                if (Gamebase.IsSuccess(error) == true)
                {
                    SetUserIdOfIndicatorReport();
                }
                callback(authToken, error);
            };

            int handle = GamebaseCallbackHandler.RegisterCallback(loginCallback);

            auth.LoginForLastLoggedInProvider(handle);
        }
        public void Login(string providerName, Dictionary <string, object> additionalInfo, GamebaseCallback.GamebaseDelegate <GamebaseResponse.Auth.AuthToken> callback)
        {
            GamebaseCallback.GamebaseDelegate <GamebaseResponse.Auth.AuthToken> loginCallback = (authToken, error) =>
            {
                if (Gamebase.IsSuccess(error) == true)
                {
                    SetUserIdOfIndicatorReport();
                }
                callback(authToken, error);
            };

            int handle = GamebaseCallbackHandler.RegisterCallback(loginCallback);

            auth.Login(providerName, additionalInfo, handle);
        }
Exemple #21
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);
                }
            });
        }
Exemple #22
0
        public GamebaseResponse.Auth.AuthProviderProfile GetAuthProviderProfile(string providerName)
        {
            if (GamebaseAuthProvider.GUEST == providerName)
            {
                GamebaseLog.Debug("Guest does not have profile information.", this);
                return(null);
            }

            if (true == string.IsNullOrEmpty(Gamebase.GetUserID()))
            {
                GamebaseLog.Debug(GamebaseStrings.NOT_LOGGED_IN, this);
                return(null);
            }

            return(AuthAdapterManager.Instance.GetIDPData <GamebaseResponse.Auth.AuthProviderProfile>(providerName, AuthAdapterManager.MethodName.GET_IDP_PROFILE));
        }
Exemple #23
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);
        }
        public static WebSocketRequest.RequestVO GetWithdrawMessage()
        {
            var vo = new AuthRequest.WithdrawVO();

            vo.parameter.appId  = GamebaseUnitySDK.AppID;
            vo.parameter.userId = Gamebase.GetUserID();

            WebSocketRequest.RequestVO requestVO = new WebSocketRequest.RequestVO(
                Lighthouse.API.Gateway.PRODUCT_ID,
                Lighthouse.API.VERSION,
                GamebaseUnitySDK.AppID);

            requestVO.apiId      = Lighthouse.API.Gateway.ID.WITHDRAW;
            requestVO.parameters = vo.parameter;

            return(requestVO);
        }
    public void GamebaseLogin()
    {
        Gamebase.Login(GamebaseAuthProvider.GUEST, (authToken, error) =>
        {
            if (Gamebase.IsSuccess(error))
            {
                Debug.Log(string.Format("Login succeeded. Gamebase userId is {0}, token {1}", authToken.member.userId, authToken.token.accessToken));

                GamebaseInfo.Instance.GamebaseUserId = authToken.member.userId;
                GamebaseInfo.Instance.GamebaseToken  = authToken.token.accessToken;
                GamebaseInfo.Instance.SetGamebaseInfo(string.Format("GameServerIP:{0}, GameServerPort:{1}, Gamebase UserId:{2}", GamebaseInfo.Instance.GameServerIp, GamebaseInfo.Instance.GameServerPort, GamebaseInfo.Instance.GamebaseUserId));
            }
            else
            {
                Debug.Log(string.Format("Login failed. error is {0}", error));
            }
        });
    }
        public static WebSocketRequest.RequestVO GetIssueShortTermTicketMessage(string purpose, int expiresIn)
        {
            AuthRequest.IssueShortTermTicketVO vo = new AuthRequest.IssueShortTermTicketVO();

            vo.parameter.userId    = Gamebase.GetUserID();
            vo.parameter.purpose   = purpose;
            vo.parameter.expiresIn = expiresIn;

            WebSocketRequest.RequestVO requestVO = new WebSocketRequest.RequestVO(
                Lighthouse.API.Gateway.PRODUCT_ID,
                Lighthouse.API.VERSION,
                GamebaseUnitySDK.AppID);

            requestVO.apiId      = Lighthouse.API.Gateway.ID.ISSUE_SHORT_TERM_TICKET;
            requestVO.parameters = vo.parameter;

            return(requestVO);
        }
Exemple #27
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);
                }
            });
        }
        public void CompletePurchase(GamebaseResponse.Purchase.PurchasableReceipt purchasableReceipt)
        {
            if (string.IsNullOrEmpty(Gamebase.GetUserID()) == true)
            {
                GamebaseLog.Warn("Not LoggedIn", this, "CompletePurchase");
                return;
            }

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

            AnalyticsRequest.PurchaseVO vo = new AnalyticsRequest.PurchaseVO();
            vo.parameter.userId = Gamebase.GetUserID();

            vo.payload.appId             = GamebaseUnitySDK.AppID;
            vo.payload.paySeq            = purchasableReceipt.paymentSeq;
            vo.payload.clientVersion     = GamebaseUnitySDK.AppVersion;
            vo.payload.idPCode           = IdPCode;
            vo.payload.deviceModel       = GamebaseUnitySDK.DeviceModel;
            vo.payload.osCode            = GamebaseUnitySDK.Platform;
            vo.payload.usimCountryCode   = "ZZ";
            vo.payload.deviceCountryCode = GamebaseUnitySDK.CountryCode;
            vo.payload.userMetaData      = MakeUserMetaData();

            var requestVO = new WebSocketRequest.RequestVO(PRODUCT_ID, Lighthouse.API.VERSION, GamebaseUnitySDK.AppID);

            requestVO.apiId      = ID.COMPLETE_PURCHASE;
            requestVO.parameters = vo.parameter;
            requestVO.payload    = JsonMapper.ToJson(vo.payload);

            WebSocket.Instance.Request(requestVO, (response, error) =>
            {
                if (Gamebase.IsSuccess(error) == false)
                {
                    GamebaseLog.Warn(
                        string.Format(
                            "{0}\n{1}",
                            "Failed request.",
                            GamebaseJsonUtil.ToPrettyJsonString(error)),
                        this,
                        "CompletePurchase");
                }
            });
        }
        private string HealthCheckURL()
        {
            switch (GamebaseUnitySDK.ZoneType)
            {
            case "real":
                var info = string.Format("/tcgb-gateway/{0}/apps/{1}/health", Lighthouse.API.VERSION, GamebaseUnitySDK.AppID);

                if (GamebaseUnitySDK.IsInitialized == false)
                {
                    return("https://api-gamebase.cloud.toast.com/tcgb-gateway/v1.0/apps/MASf2WiO/health");
                }

                return((Gamebase.IsSandbox()) ?
                       string.Format("https://sandbox-api-gamebase.cloud.toast.com{0}", info) :
                       string.Format("https://api-gamebase.cloud.toast.com{0}", info));

            default:
                return("https://sandbox-api-gamebase.cloud.toast.com/tcgb-gateway/v1.0/apps/gwJZCFnR/health");
            }
        }
        public void GetIDPCredentialInfo(string providerName, GamebaseCallback.GamebaseDelegate <Dictionary <string, object> > callback)
        {
            Dictionary <string, object> credentialInfo = null;

            IDPLogin((adapterError) =>
            {
                if (Gamebase.IsSuccess(adapterError))
                {
                    credentialInfo = new Dictionary <string, object>();
                    credentialInfo.Add(GamebaseAuthProviderCredential.PROVIDER_NAME, providerName);
                    credentialInfo.Add(GamebaseAuthProviderCredential.ACCESS_TOKEN, GetIDPAccessToken(providerName));
                }
                else
                {
                    GamebaseLog.Debug(string.Format("error:{0}", adapterError), this, "GetCredentialInfo");
                }

                callback(credentialInfo, adapterError);
            });
        }