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; } } }
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; } } }
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); }); }
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(); } }
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 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); } }
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 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); }
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 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 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"); } }); }
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); }); }
public void RequestItemListPurchasable(int handle) { var callback = GamebaseCallbackHandler.GetCallback <GamebaseCallback.GamebaseDelegate <List <GamebaseResponse.Purchase.PurchasableItem> > >(handle); if (IsLoggedIn() == false) { callback(null, new GamebaseError(GamebaseErrorCode.NOT_LOGGED_IN, Domain)); return; } bool hasAdapter = PurchaseAdapterManager.Instance.CreateIDPAdapter("iapadapter"); if (hasAdapter == false) { GamebaseErrorNotifier.FireNotSupportedAPI( this, "RequestItemListPurchasable", GamebaseCallbackHandler.GetCallback <GamebaseCallback.GamebaseDelegate <List <GamebaseResponse.Purchase.PurchasableItem> > >(handle)); return; } PurchaseAdapterManager.Instance.RequestItemListPurchasable((error) => { GamebaseSystemPopup.Instance.ShowErrorPopup(error); if (callback == null) { return; } if (Gamebase.IsSuccess(error)) { callback(PurchaseAdapterManager.Instance.GetPurchasableReceiptList(), null); return; } error.domain = Domain; callback(null, error); }); }
private IEnumerator RetryConnect() { if (requestQueueItem.retryCount < requestQueueItem.retryLimits) { yield return(new WaitForSecondsRealtime(RETRY_CONNECT_DELAY)); yield return(GamebaseUnitySDKSettings.Instance.StartCoroutine(InternetReachability((reachable) => { if (true == reachable) { GamebaseUnitySDKSettings.Instance.StartCoroutine(socket.Reconnect((error) => { if (true == Gamebase.IsSuccess(error)) { RequestEnqueue(requestQueueItem); requestQueueItem = null; return; } RetryItem(); })); } else { RetryItem(); } GamebaseLog.Debug(string.Format("index:{0}, apiId:{1}, retryCount:{2}, internetReachability:{3}", requestQueueItem.index, requestQueueItem.requestVO.apiId, requestQueueItem.retryCount, reachable), this, "RetryConnect"); }))); } else { GamebaseLog.Debug(string.Format("Reconnect failed. Index of queue item:{0}", requestQueueItem.index), this, "RetryConnect"); requestQueueItem.callback(string.Empty, new GamebaseError(GamebaseErrorCode.SOCKET_ERROR)); requestQueueItem = null; } }
public void GamebaseInitialize() { Gamebase.Initialize((launchingInfo, error) => { if (Gamebase.IsSuccess(error) == true) { Debug.Log("Initialization succeeded."); var serverInfo = launchingInfo.launching.app.accessInfo.serverAddress; if (serverInfo != null) { var serverData = serverInfo.Split(':'); GamebaseInfo.Instance.GameServerIp = serverData[0]; GamebaseInfo.Instance.GameServerPort = serverData[1]; GamebaseInfo.Instance.SetGamebaseInfo(string.Format("GameServerIP:{0}, GameServerPort:{1}", GamebaseInfo.Instance.GameServerIp, GamebaseInfo.Instance.GameServerPort)); } GamebaseLogin(); //Following notices are registered in the Gamebase Console var notice = launchingInfo.launching.notice; if (notice != null) { if (string.IsNullOrEmpty(notice.message) == false) { Debug.Log(string.Format("title:{0}", notice.title)); Debug.Log(string.Format("message:{0}", notice.message)); Debug.Log(string.Format("url:{0}", notice.url)); } } //Status information of game app version set in the Gamebase Unity SDK initialization. var status = launchingInfo.launching.status; // Game status code (e.g. Under maintenance, Update is required, Service has been terminated) // refer to GamebaseLaunchingStatus if (status.code == GamebaseLaunchingStatus.IN_SERVICE) { // Service is now normally provided. } else { switch (status.code) { case GamebaseLaunchingStatus.RECOMMEND_UPDATE: { // Update is recommended. break; } // ... case GamebaseLaunchingStatus.INTERNAL_SERVER_ERROR: { // Error in internal server. break; } } } } else { // Check the error code and handle the error appropriately. Debug.Log(string.Format("Initialization failed. error is {0}", error)); } }); }
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 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); }); }
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); }); }