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 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 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); }); }
public void RequestPurchase(long itemSeq, int handle) { GamebaseCallback.GamebaseDelegate <GamebaseResponse.Purchase.PurchasableReceipt> puechaseCallback = (purchasableReceipt, error) => { GamebaseResponse.Launching.LaunchingInfo launchingInfo = GamebaseLaunchingImplementation.Instance.GetLaunchingInformations(); if (Gamebase.IsSuccess(error) == true) { GamebaseIndicatorReport.SendIndicatorData( GamebaseIndicatorReportType.LogType.PURCHASE, GamebaseIndicatorReportType.StabilityCode.GB_IAP_PURCHASE_SUCCESS, GamebaseIndicatorReportType.LogLevel.INFO, new Dictionary <string, string>() { { GamebaseIndicatorReportType.AdditionalKey.GB_TCIAP_APP_KEY, launchingInfo.tcProduct.iap.appKey }, { GamebaseIndicatorReportType.AdditionalKey.GB_ITEM_SEQ, itemSeq.ToString() } }); } else { if (error.code == GamebaseErrorCode.PURCHASE_USER_CANCELED) { GamebaseIndicatorReport.SendIndicatorData( GamebaseIndicatorReportType.LogType.PURCHASE, GamebaseIndicatorReportType.StabilityCode.GB_IAP_PURCHASE_CANCELED, GamebaseIndicatorReportType.LogLevel.DEBUG, new Dictionary <string, string>() { { GamebaseIndicatorReportType.AdditionalKey.GB_TCIAP_APP_KEY, launchingInfo.tcProduct.iap.appKey }, { GamebaseIndicatorReportType.AdditionalKey.GB_ITEM_SEQ, itemSeq.ToString() } }, error, true); } else { GamebaseIndicatorReport.SendIndicatorData( GamebaseIndicatorReportType.LogType.PURCHASE, GamebaseIndicatorReportType.StabilityCode.GB_IAP_PURCHASE_FAILED, GamebaseIndicatorReportType.LogLevel.DEBUG, new Dictionary <string, string>() { { GamebaseIndicatorReportType.AdditionalKey.GB_TCIAP_APP_KEY, launchingInfo.tcProduct.iap.appKey }, { GamebaseIndicatorReportType.AdditionalKey.GB_ITEM_SEQ, itemSeq.ToString() } }, error, true); } } var callback = GamebaseCallbackHandler.GetCallback <GamebaseCallback.GamebaseDelegate <GamebaseResponse.Purchase.PurchasableReceipt> >(handle); if (callback != null) { callback(purchasableReceipt, error); } GamebaseCallbackHandler.UnregisterCallback(handle); }; if (IsLoggedIn() == false) { puechaseCallback(null, new GamebaseError(GamebaseErrorCode.NOT_LOGGED_IN, Domain)); return; } PurchaseAdapterManager.Instance.RequestPurchase( itemSeq, (receipt, error) => { if (Gamebase.IsSuccess(error) == true) { GamebaseAnalytics.Instance.CompletePurchase(receipt); } else { } puechaseCallback(receipt, error); }); }
private void SendHeartbeat() { var requestVO = HeartbeatMessage.GetHeartbeatMessage(); WebSocket.Instance.Request(requestVO, (response, error) => { GamebaseError heartbeatError = error; if (null == heartbeatError) { var vo = JsonMapper.ToObject <LaunchingResponse.HeartbeatInfo>(response); if (true == vo.header.isSuccessful) { GamebaseLog.Debug("Send heartbeat succeeded", this); } else { heartbeatError = GamebaseErrorUtil.CreateGamebaseErrorByServerErrorCode(requestVO.transactionId, requestVO.apiId, vo.header, string.Empty); } } if (null != heartbeatError) { if (GamebaseErrorCode.BANNED_MEMBER == heartbeatError.code || GamebaseErrorCode.INVALID_MEMBER == heartbeatError.code) { var vo = new GamebaseResponse.SDK.ObserverMessage(); vo.type = GamebaseObserverType.HEARTBEAT; vo.data = new System.Collections.Generic.Dictionary <string, object>(); vo.data.Add("code", heartbeatError.code); if (GamebaseErrorCode.BANNED_MEMBER == heartbeatError.code) { GamebaseIndicatorReport.SendIndicatorData( GamebaseIndicatorReportType.LogType.EVENT, GamebaseIndicatorReportType.StabilityCode.GB_EVENT_OBSERVER_BANNED_MEMBER, GamebaseIndicatorReportType.LogLevel.INFO, new Dictionary <string, string>() { { GamebaseIndicatorReportType.AdditionalKey.GB_OBSERVER_DATA, JsonMapper.ToJson(vo) } }); } else { GamebaseIndicatorReport.SendIndicatorData( GamebaseIndicatorReportType.LogType.EVENT, GamebaseIndicatorReportType.StabilityCode.GB_EVENT_OBSERVER_INVALID_MEMBER, GamebaseIndicatorReportType.LogLevel.INFO, new Dictionary <string, string>() { { GamebaseIndicatorReportType.AdditionalKey.GB_OBSERVER_DATA, JsonMapper.ToJson(vo) } }); } GamebaseSystemPopup.Instance.ShowHeartbeatErrorPopup(heartbeatError); var observerCallback = GamebaseCallbackHandler.GetCallback <GamebaseCallback.DataDelegate <GamebaseResponse.SDK.ObserverMessage> >(GamebaseObserverManager.Instance.Handle); if (null != observerCallback) { observerCallback(vo); } } GamebaseLog.Debug(string.Format("Send heartbeat failed. error:{0}", GamebaseJsonUtil.ToPrettyJsonString(heartbeatError)), this); } lastSentTime = DateTime.Now; }); }