Ejemplo n.º 1
0
        void OnEnteredForeground()
        {
            var since = Time.Since(_enteredBackground);

            EB.Debug.Log("OnEnteredForeground: since: {0}", since);
            EB.Debug.Log("OnEnteredForeground: reachability: {0}", Application.internetReachability);
            EB.Debug.Log("OnEnteredForeground: _wasLoggedIn: {0}, _wasServiceActive: {1}", _wasLoggedIn, _wasServiceActive);

            if (_wasLoggedIn)
            {
                var ping = ApiEndPoint.Post("/util/ping");
                ping.suspendMethod = Request.eSuspendMethod.Break;
                ApiEndPoint.Service(ping, delegate(Response r)
                {
                    if (r.sucessful)
                    {
                        EB.Debug.Log("OnEnteredForeground: ping is ok!");
                        ApiEndPoint.StartKeepAlive();
                    }
                    else
                    {
                        EB.Debug.Log("OnEnteredForeground: sesstion timedout, re-login");
                        Disconnect(false);
                    }
                });

                for (int i = 0, cnt = _managers.Count; i < cnt; ++i)
                {
                    var manager = _managers[i];
                    manager.OnEnteredForeground();
                }
            }

            _enteredBackground = 0;
        }
Ejemplo n.º 2
0
        void SubSystemConnecting()
        {
            var allConnected = true;

            for (int i = 0, cnt = _subsystems.Count; i < cnt; ++i)
            {
                SubSystem system = _subsystems[i];
                switch (system.State)
                {
                case SubSystemState.Error:
                {
                    FatalError(Localizer.GetString("ID_SPARX_ERROR_UNKNOWN"));
                    return;
                }

                case SubSystemState.Connecting:
                case SubSystemState.Disconnected:
                {
                    allConnected = false;
                    return;
                }

                case SubSystemState.Connected:
                {
                }
                break;
                }
            }

            if (allConnected)
            {
                EB.Debug.Log("SparxHub: SubSystemConnected");
                State = HubState.Connected;

                ApiEndPoint.StartKeepAlive();

                if (Config.LoginConfig.Listener != null)
                {
                    Config.LoginConfig.Listener.OnLoggedIn();
                }

                for (int i = 0, cnt = _managers.Count; i < cnt; ++i)
                {
                    var manager = _managers[i];
                    EB.Debug.Log("manager.OnLoggedIn()===>{0}", manager.GetType().FullName);
                    manager.OnLoggedIn();
                }
            }
        }