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); }); }
public void RequestLaunchingStatus(int handle = -1) { GamebaseLog.Debug("Check Launching Status", this); statusElaspedTime = 0; requestVO.apiId = Lighthouse.API.Launching.ID.GET_LAUNCHING_STATUS; WebSocket.Instance.Request(requestVO, (response, error) => { GamebaseSystemPopup.Instance.ShowErrorPopup(error); if (null != error) { return; } var launchingInfo = DataContainer.GetData <LaunchingResponse.LaunchingInfo>(VOKey.Launching.LAUNCHING_INFO); var launchingStatus = JsonMapper.ToObject <LaunchingResponse.LaunchingStatus>(response); if (launchingInfo.launching.status.code == launchingStatus.launching.status.code) { OnLaunchingInfoCallback(handle); return; } GamebaseLog.Debug("Check Launching Info", this); GamebaseCallback.GamebaseDelegate <GamebaseResponse.Launching.LaunchingInfo> launchingInfoCallback = (launchingInfoTemp, errorTemp) => { var launchingStatusCallback = GamebaseCallbackHandler.GetCallback <GamebaseCallback.DataDelegate <GamebaseResponse.Launching.LaunchingStatus> >(scheduleHandle); if (null != launchingStatusCallback) { var vo = new GamebaseResponse.Launching.LaunchingStatus(); vo.code = launchingStatus.launching.status.code; vo.message = launchingStatus.launching.status.message; launchingStatusCallback(vo); } var observerCallback = GamebaseCallbackHandler.GetCallback <GamebaseCallback.DataDelegate <GamebaseResponse.SDK.ObserverMessage> >(GamebaseObserverManager.Instance.Handle); if (null != observerCallback) { var vo = new GamebaseResponse.SDK.ObserverMessage(); vo.type = GamebaseObserverType.LAUNCHING; vo.data = new System.Collections.Generic.Dictionary <string, object>(); vo.data.Add("code", launchingStatus.launching.status.code); vo.data.Add("message", launchingStatus.launching.status.message); observerCallback(vo); } OnLaunchingInfoCallback(handle); }; int handleTemp = GamebaseCallbackHandler.RegisterCallback(launchingInfoCallback); GetLaunchingInfo(handleTemp); }); }
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); }); }
protected void CheckLaunchingStatusExpire(Action callback) { if (CanLaunchingStatusUpdate() == true) { GamebaseCallback.GamebaseDelegate <GamebaseResponse.Launching.LaunchingInfo> launchingInfoCallback = (launchingInfo, error) => { callback(); }; int handle = GamebaseCallbackHandler.RegisterCallback(launchingInfoCallback); GamebaseLaunchingImplementation.Instance.RequestLaunchingStatus(handle); return; } callback(); }
protected void CheckLaunchingStatusExpire(Action callback) { if (CommunicatorConfiguration.launchingExpire >= GamebaseLaunchingImplementation.Instance.GetLaunchingStatusExpire()) { GamebaseCallback.GamebaseDelegate <GamebaseResponse.Launching.LaunchingInfo> launchingInfoCallback = (launchingInfo, error) => { callback(); }; int handle = GamebaseCallbackHandler.RegisterCallback(launchingInfoCallback); GamebaseLaunchingImplementation.Instance.RequestLaunchingStatus(handle); return; } callback(); }
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()); }
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); }); }
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); }); }
public void Logout(int handle) { GamebaseCallback.ErrorDelegate logoutCallback = (error) => { if (Gamebase.IsSuccess(error) == true) { GamebaseIndicatorReport.SendIndicatorData( GamebaseIndicatorReportType.LogType.AUTH, GamebaseIndicatorReportType.StabilityCode.GB_AUTH_LOGOUT_SUCCESS, GamebaseIndicatorReportType.LogLevel.INFO, new Dictionary <string, string>() { { GamebaseIndicatorReportType.AdditionalKey.GB_SUB_CATEGORY1, GamebaseIndicatorReportType.SubCategory.LOGOUT } }); } else { GamebaseIndicatorReport.SendIndicatorData( GamebaseIndicatorReportType.LogType.AUTH, GamebaseIndicatorReportType.StabilityCode.GB_AUTH_LOGOUT_FAILED, GamebaseIndicatorReportType.LogLevel.ERROR, new Dictionary <string, string>() { { GamebaseIndicatorReportType.AdditionalKey.GB_SUB_CATEGORY1, GamebaseIndicatorReportType.SubCategory.LOGOUT } }, error); } var callback = GamebaseCallbackHandler.GetCallback <GamebaseCallback.ErrorDelegate>(handle); if (callback != null) { callback(null); } GamebaseCallbackHandler.UnregisterCallback(handle); }; int logoutHandle = GamebaseCallbackHandler.RegisterCallback(logoutCallback); if (CanLogout(logoutHandle) == false) { return; } var requestVO = AuthMessage.GetLogoutMessage(); WebSocket.Instance.Request(requestVO, (response, error) => { GamebaseAnalytics.Instance.IdPCode = string.Empty; GamebaseSystemPopup.Instance.ShowErrorPopup(error); var callback = GamebaseCallbackHandler.GetCallback <GamebaseCallback.ErrorDelegate>(logoutHandle); if (callback == null) { return; } GamebaseCallbackHandler.UnregisterCallback(logoutHandle); RemoveLoginData(); callback(error); }); }