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 void OnObserverEvent(GamebaseResponse.SDK.ObserverMessage message) { if (null != observerSet && 0 < observerSet.Count) { foreach (var observer in observerSet) { if (null != observer) { observer(message); } } } }
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, "SendHeartbeat"); } 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) { GamebaseSystemPopup.Instance.ShowHeartbeatErrorPopup(heartbeatError); var observerCallback = GamebaseCallbackHandler.GetCallback <GamebaseCallback.DataDelegate <GamebaseResponse.SDK.ObserverMessage> >(GamebaseObserverManager.Instance.Handle); if (null != observerCallback) { 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); observerCallback(vo); } } GamebaseLog.Debug(string.Format("Send heartbeat failed. error:{0}", heartbeatError), this, "SendHeartbeat"); } lastSentTime = DateTime.Now; }); }
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; }); }