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); } }); }
protected void RequestGamebaseLogin(WebSocketRequest.RequestVO requestVO, int handle) { isAuthenticationAlreadyProgress = true; WebSocket.Instance.Request(requestVO, (response, error) => { var callback = GamebaseCallbackHandler.GetCallback <GamebaseCallback.GamebaseDelegate <GamebaseResponse.Auth.AuthToken> >(handle); if (null == callback) { return; } GamebaseCallbackHandler.UnregisterCallback(handle); if (null == error) { AuthRequest.LoginVO.Payload payload = JsonMapper.ToObject <AuthRequest.LoginVO.Payload>(requestVO.payload); GamebaseAnalytics.Instance.IdPCode = payload.idPInfo.idPCode; var vo = JsonMapper.ToObject <AuthResponse.LoginInfo>(response); if (true == vo.header.isSuccessful) { DataContainer.SetData(VOKey.Auth.LOGIN_INFO, vo); Heartbeat.Instance.StartHeartbeat(); Introspect.Instance.StartIntrospect(); } else { error = GamebaseErrorUtil.CreateGamebaseErrorByServerErrorCode(requestVO.transactionId, requestVO.apiId, vo.header, Domain); if (null != vo.ban) { DataContainer.SetData(VOKey.Auth.BAN_INFO, vo.ban); GamebaseSystemPopup.Instance.ShowErrorPopup(error, vo); } } } else { GamebaseSystemPopup.Instance.ShowErrorPopup(error); } isAuthenticationAlreadyProgress = false; if (error == null) { GamebaseLog.Debug("ToastSdk UserId", this); GamebaseResponse.Auth.AuthToken authToken = JsonMapper.ToObject <GamebaseResponse.Auth.AuthToken>(response); ToastSdk.UserId = authToken.member.userId; AuthRequest.LoginVO.Payload payload = JsonMapper.ToObject <AuthRequest.LoginVO.Payload>(requestVO.payload); SetIapExtraData(payload.idPInfo.idPCode); GamebaseLog.Debug("GamebaseIapManager Initialize", this); PurchaseAdapterManager.Instance.Initialize(); callback(authToken, error); } else { callback(null, error); } }); }
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); }); }