private IEnumerator Send()
        {
            if (false == socket.IsConnected())
            {
                yield return(GamebaseCoroutineManager.StartCoroutine(GamebaseGameObjectManager.GameObjectType.WEBSOCKET_TYPE, RetryConnect()));

                yield break;
            }
            else
            {
                if (0 < requestQueueItem.retryCount)
                {
                    GamebaseLog.Debug(string.Format("Reconnect succeeded. Index of queue item:{0}", requestQueueItem.index), this);
                }
            }

            GamebaseLog.Debug(string.Format("request:{0}", GamebaseJsonUtil.ToPrettyJsonString(requestQueueItem.requestVO)), this);
            yield return(GamebaseCoroutineManager.StartCoroutine(GamebaseGameObjectManager.GameObjectType.WEBSOCKET_TYPE, socket.Send(JsonMapper.ToJson(requestQueueItem.requestVO), (error) =>
            {
                if (null == error)
                {
                    return;
                }

                error.transactionId = requestQueueItem.requestVO.transactionId;
                requestQueueItem.callback(string.Empty, error);
            })));

            socket.SetPollingInterval(PollingIntervalType.SHORT_INTERVAL);
            GamebaseCoroutineManager.StartCoroutine(GamebaseGameObjectManager.GameObjectType.WEBSOCKET_TYPE, CheckTimeout());
        }
        public void SetRemoteSettings(GamebaseResponse.Launching.LaunchingInfo launchingInfo)
        {
            if (launchingInfo == null ||
                launchingInfo.launching == null ||
                launchingInfo.launching.tcgbClient == null)
            {
                return;
            }

            var forceRemoteSettings = launchingInfo.launching.tcgbClient.forceRemoteSettings;

            if (forceRemoteSettings != null)
            {
                GamebaseLog.Debug(GamebaseJsonUtil.ToPrettyJsonString(forceRemoteSettings), this);

                logSetting.Initialize(forceRemoteSettings.log.policy, forceRemoteSettings.log.indicator);

                GamebaseLog.SetDebugLog(logSetting.IsDebugMode(isDebugMode));

                GamebaseLogReport.Instance.Initialize(
                    logSetting.IsIndicatorMode(),
                    forceRemoteSettings.log.appKeyIndicator,
                    forceRemoteSettings.log.appKeyLog);
            }
            else
            {
                GamebaseLog.Debug("ForceRemoteSettings is null", this);
            }
        }
        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");
                }
            });
        }
        public string GetSync(string jsonString)
        {
            GamebaseLog.Debug(string.Format("jsonString : {0}", GamebaseJsonUtil.ToPrettyJsonString(jsonString)), this);

            string retValue = jc.CallStatic <string>("getSync", jsonString);

            if (string.IsNullOrEmpty(retValue) == false)
            {
                GamebaseLog.Debug(string.Format("retValue : {0}", retValue), this);
            }

            return(retValue);
        }
        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");
                }
            });
        }
예제 #6
0
        public string GetSync(string jsonString)
        {
            GamebaseLog.Debug(string.Format("jsonString : {0}", GamebaseJsonUtil.ToPrettyJsonString(jsonString)), this);

            string retValue = string.Empty;
            IntPtr result   = getSync(jsonString);

            if (IntPtr.Zero != result)
            {
                retValue = Marshal.PtrToStringAnsi(result);
            }

            if (string.IsNullOrEmpty(retValue) == false)
            {
                GamebaseLog.Debug(string.Format("retValue : {0}", retValue), this);
            }

            return(retValue);
        }
        private void RecvEvent(string response)
        {
            GamebaseLog.Debug(GamebaseJsonUtil.ToPrettyJsonString(response), this);

            ProtocolResponse protocol = JsonMapper.ToObject <ProtocolResponse>(response);

            if (null != protocol.header.serverPush)
            {
                ServerPush.Instance.OnServerPush(response);
                return;
            }

            if (protocol.header.transactionId == requestQueueItem.requestVO.transactionId)
            {
                requestQueueItem.callback(response, null);
                isTimeOutCheck   = false;
                requestQueueItem = null;
                socket.SetPollingInterval(PollingIntervalType.LONG_INTERVAL);
            }
            else
            {
                GamebaseLog.Debug(string.Format("Missing response TransactionId : {0}", protocol.header.transactionId.ToString()), this);
            }
        }
예제 #8
0
 private void OnError(object sender, ErrorEventArgs e)
 {
     errorMessage = e.Message;
     GamebaseLog.Warn(GamebaseJsonUtil.ToPrettyJsonString(e), this);
 }
        public void GetAsync(string jsonString)
        {
            GamebaseLog.Debug(string.Format("jsonString : {0}", GamebaseJsonUtil.ToPrettyJsonString(jsonString)), this);

            jc.CallStatic("getAsync", jsonString);
        }
예제 #10
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;
            });
        }