private void SendIntrospect()
        {
            GamebaseLog.Debug("Send Introspect", this);
            var requestVO = IntrospectMessage.MakeIntrospectMessage();

            WebSocket.Instance.Request(requestVO, (response, error) =>
            {
                GamebaseError introspectError = error;

                if (introspectError == null)
                {
                    var vo = JsonMapper.ToObject <LaunchingResponse.IntrospectInfo>(response);
                    if (vo.header.isSuccessful == true)
                    {
                        GamebaseLog.Debug("Send Introspect succeeded", this);
                        retryCount       = 0;
                        sentIntervalTime = refrashIntervalTime;
                        return;
                    }
                    else
                    {
                        introspectError = GamebaseErrorUtil.CreateGamebaseErrorByServerErrorCode(requestVO.transactionId, requestVO.apiId, vo.header, string.Empty);
                    }
                }

                if (introspectError != null)
                {
                    if (introspectError.code == GamebaseErrorCode.SOCKET_RESPONSE_TIMEOUT || introspectError.code == GamebaseErrorCode.SOCKET_ERROR)
                    {
                        sentIntervalTime = retryIntervalTime;
                        retryCount++;

                        if (retryCount <= MAX_RETRY_COUNT)
                        {
                            return;
                        }
                    }

                    retryCount = 0;

                    StopIntrospect();
                    SendObserverEvent(introspectError);
                }
            });
        }
        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;
            });
        }
Esempio n. 3
0
        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;
            });
        }