Beispiel #1
0
        private IEnumerator Init()
        {
            yield return(DisplayLanguage.Instance.DisplayLanguageInitialize());

            WebSocket.Instance.Initialize();
            yield return(GamebaseCoroutineManager.StartCoroutine(GamebaseGameObjectManager.GameObjectType.CORE_TYPE, WebSocket.Instance.Connect((error) =>
            {
                GamebaseSystemPopup.Instance.ShowErrorPopup(error);

                if (error == null)
                {
                    GamebaseLaunchingImplementation.Instance.RequestLaunchingInfo(initializeHandle);
                    return;
                }

                var callback = GamebaseCallbackHandler.GetCallback <GamebaseCallback.GamebaseDelegate <GamebaseResponse.Launching.LaunchingInfo> >(initializeHandle);

                if (callback != null)
                {
                    error.domain = Domain;
                    callback(null, error);
                }

                GamebaseCallbackHandler.UnregisterCallback(initializeHandle);
                initializeHandle = -1;
            })));
        }
Beispiel #2
0
 public IEnumerator DisplayLanguageInitialize()
 {
     if (null == localizedStrings)
     {
         yield return(GamebaseCoroutineManager.StartCoroutine(GamebaseGameObjectManager.GameObjectType.DISPLAY_LANGUAGE_TYPE, LoadLocalizedString()));
     }
 }
        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());
        }
Beispiel #4
0
 public void StartRecvPolling()
 {
     if (null != recvPolling)
     {
         StopRecvPolling();
     }
     recvPolling = GamebaseCoroutineManager.StartCoroutine(GamebaseGameObjectManager.GameObjectType.WEBSOCKET_TYPE, RecvPolling());
 }
Beispiel #5
0
 public void StopRecvPolling()
 {
     if (null != recvPolling)
     {
         GamebaseCoroutineManager.StopCoroutine(GamebaseGameObjectManager.GameObjectType.WEBSOCKET_TYPE, recvPolling);
         recvPolling = null;
     }
 }
        private void RequestEnqueue(RequestQueueItem item)
        {
            requestQueue.Enqueue(item);

            if (false == isRequestQueueCheck)
            {
                isRequestQueueCheck = true;
                GamebaseCoroutineManager.StartCoroutine(GamebaseGameObjectManager.GameObjectType.WEBSOCKET_TYPE, UpdateQueue());
            }
        }
Beispiel #7
0
        private void ExecuteSchedule()
        {
            GamebaseLog.Debug("Start Launching Status Schedule", this);

            if (isPlaySchedule == true)
            {
                return;
            }

            isPlaySchedule = true;
            GamebaseCoroutineManager.StartCoroutine(GamebaseGameObjectManager.GameObjectType.LAUNCHING_TYPE, ScheduleLaunchingStatus());
        }
Beispiel #8
0
        public void StartHeartbeat()
        {
            if (false == IsSendable())
            {
                return;
            }

            GamebaseLog.Debug("Start Heartbeat", this);

            status = HeartbeatStatus.Start;
            GamebaseCoroutineManager.StartCoroutine(GamebaseGameObjectManager.GameObjectType.HEARTBEAT_TYPE, ExecuteHeartbeat());
        }
Beispiel #9
0
        private IEnumerator LoadLocalizedString()
        {
            string filePath = Path.Combine(Application.streamingAssetsPath, "Gamebase/localizedstring.json");

            if (true == IsWebFilePath(filePath))
            {
                yield return(GamebaseCoroutineManager.StartCoroutine(GamebaseGameObjectManager.GameObjectType.DISPLAY_LANGUAGE_TYPE, LoadWebFile(filePath)));
            }
            else
            {
                LoadLocalFile(filePath);
            }
        }
        public void StartIntrospect()
        {
            if (IsSendable() == false)
            {
                return;
            }

            GamebaseLog.Debug("Start Introspect", this);

            sentIntervalTime = refrashIntervalTime;
            sentStandardTime = Time.realtimeSinceStartup;

            GamebaseCoroutineManager.StartCoroutine(GamebaseGameObjectManager.GameObjectType.INTROSPECT_TYPE, ExecuteIntrospect());
        }
Beispiel #11
0
 public void LoadStringFromFile(string filePath, System.Action <string> callback)
 {
     if (IsWebFilePath(filePath) == true)
     {
         GamebaseCoroutineManager.StartCoroutine(
             GamebaseGameObjectManager.GameObjectType.STRING_LOADER,
             LoadWebFile(
                 filePath,
                 callback));
     }
     else
     {
         LoadLocalFile(filePath, callback);
     }
 }
        public IEnumerator Reconnect(GamebaseCallback.ErrorDelegate callback)
        {
            GamebaseLog.Debug(string.Format("SocketState:{0}", SocketState(nativeRef)), this);

            if (DEFAULT_NATIVE_REF != nativeRef)
            {
                if ((int)WebSocketState.Open == SocketState(nativeRef))
                {
                    callback(null);
                    yield break;
                }
            }

            Close();
            yield return(GamebaseCoroutineManager.StartCoroutine(GamebaseGameObjectManager.GameObjectType.WEBSOCKET_TYPE, Connect(callback)));
        }
Beispiel #13
0
        public IEnumerator Send(string jsonString, GamebaseCallback.ErrorDelegate callback)
        {
            if (false == IsConnected())
            {
                yield return(GamebaseCoroutineManager.StartCoroutine(GamebaseGameObjectManager.GameObjectType.WEBSOCKET_TYPE, Reconnect((error) =>
                {
                    callback(error);

                    if (null == error)
                    {
                        socket.Send(jsonString);
                    }
                })));
            }
            else
            {
                socket.Send(jsonString);
            }
        }
        public void Request(WebSocketRequest.RequestVO vo, GamebaseCallback.GamebaseDelegate <string> callback)
        {
            GamebaseCoroutineManager.StartCoroutine(GamebaseGameObjectManager.GameObjectType.WEBSOCKET_TYPE, InternetReachability((reachable) =>
            {
                if (true == reachable)
                {
                    RequestEnqueue(new RequestQueueItem(itemLength++, vo, callback));
                }
                else
                {
                    if (null == callback)
                    {
                        return;
                    }

                    callback(string.Empty, new GamebaseError(GamebaseErrorCode.SOCKET_ERROR, transactionId: vo.transactionId));
                }
            }));
        }
Beispiel #15
0
        public IEnumerator Reconnect(GamebaseCallback.ErrorDelegate callback)
        {
            if (null == socket)
            {
                yield return(GamebaseCoroutineManager.StartCoroutine(GamebaseGameObjectManager.GameObjectType.WEBSOCKET_TYPE, Connect(callback)));

                yield break;
            }

            GamebaseLog.Debug(string.Format("socket.ReadyState:{0}", socket.ReadyState), this);

            if (WebSocketState.Open == socket.ReadyState)
            {
                callback(null);
                yield break;
            }

            Close();
            yield return(GamebaseCoroutineManager.StartCoroutine(GamebaseGameObjectManager.GameObjectType.WEBSOCKET_TYPE, Connect(callback)));
        }
        private IEnumerator UpdateQueue()
        {
            while (true == isRequestQueueCheck)
            {
                if (0 == requestQueue.Count)
                {
                    isRequestQueueCheck = false;
                    yield return(null);
                }
                else
                {
                    if (null == requestQueueItem)
                    {
                        requestQueueItem = RequestDequeue();
                        yield return(GamebaseCoroutineManager.StartCoroutine(GamebaseGameObjectManager.GameObjectType.WEBSOCKET_TYPE, Send()));
                    }

                    yield return(null);
                }
            }
        }
        private IEnumerator RetryConnect()
        {
            if (requestQueueItem.retryCount < requestQueueItem.retryLimits)
            {
                yield return(new WaitForSecondsRealtime(RETRY_CONNECT_DELAY));

                yield return(GamebaseCoroutineManager.StartCoroutine(GamebaseGameObjectManager.GameObjectType.WEBSOCKET_TYPE, InternetReachability((reachable) =>
                {
                    if (true == reachable)
                    {
                        GamebaseCoroutineManager.StartCoroutine(GamebaseGameObjectManager.GameObjectType.WEBSOCKET_TYPE, 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);
                })));
            }
            else
            {
                GamebaseLog.Debug(string.Format("Reconnect failed. Index of queue item:{0}", requestQueueItem.index), this);
                requestQueueItem.callback(string.Empty, new GamebaseError(GamebaseErrorCode.SOCKET_ERROR));
                requestQueueItem = null;
            }
        }
Beispiel #18
0
        private IEnumerator ExecuteHeartbeat()
        {
            if (HeartbeatStatus.Stop == status)
            {
                yield break;
            }

            var timestamp = (int)(DateTime.Now - lastSentTime).TotalSeconds;

            if (CommunicatorConfiguration.heartbeatInterval <= timestamp)
            {
                GamebaseLog.Debug(
                    string.Format(
                        "HeartbeatElaspedTime : {0} (Standard is more than {1})",
                        timestamp,
                        CommunicatorConfiguration.heartbeatInterval),
                    this);
                SendHeartbeat();
            }

            yield return(new WaitForSecondsRealtime(waitTime));

            GamebaseCoroutineManager.StartCoroutine(GamebaseGameObjectManager.GameObjectType.HEARTBEAT_TYPE, ExecuteHeartbeat());
        }
        public void StopIntrospect()
        {
            GamebaseLog.Debug("Stop Introspect", this);

            GamebaseCoroutineManager.StopAllCoroutines(GamebaseGameObjectManager.GameObjectType.INTROSPECT_TYPE);
        }
Beispiel #20
0
        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 IEnumerator Connect(GamebaseCallback.ErrorDelegate callback)
 {
     yield return(GamebaseCoroutineManager.StartCoroutine(GamebaseGameObjectManager.GameObjectType.WEBSOCKET_TYPE, socket.Connect(callback)));
 }
 public override void IsConnected(int handle)
 {
     GamebaseCoroutineManager.StartCoroutine(GamebaseGameObjectManager.GameObjectType.WEBSOCKET_TYPE, HealthCheck(handle));
 }