private void StartPingTimer()
 {
     SimpleMutex.Lock(PingMutex, () =>
     {
         PingTimer = new EngineIOTimeout(() =>
         {
             Send(EngineIOPacket.CreatePingPacket());
             ResetPongTimer(Server.Option.PingTimeout);
         }, Server.Option.PingInterval * 1.1);
     });
 }
Exemplo n.º 2
0
        protected override void CloseInternal(Action Callback)
        {
            void OnClose()
            {
                CloseTimer?.Stop();
                Callback?.Invoke();
                this.OnClose();
            }

            if (DataResponse != null)
            {
                try
                {
                    DataResponse.Headers = SetHeaders(DataResponse.Headers);
                    DataResponse.Close();
                }
                catch
                {
                }
            }

            DataRequest  = null;
            DataResponse = null;

            if (Writable)
            {
                Send(EngineIOPacket.CreateClosePacket().Encode(EngineIOTransportType.polling, ForceBase64));
                OnClose();
            }
            else if (Discarded)
            {
                OnClose();
            }
            else
            {
                ShouldClose = OnClose;
                CloseTimer  = new EngineIOTimeout(OnClose, 30 * 1000);
            }

            ConnectionTimer.Stop();
        }
 private void StartPongTimer(ulong PingTimeout)
 {
     SimpleMutex.Lock(PongMutex, () =>
     {
         PongTimer = new EngineIOTimeout(() =>
         {
             SimpleMutex.Lock(PongMutex, () =>
             {
                 if (ReadyState != EngineIOReadyState.CLOSED)
                 {
                     if (Pong > 0)
                     {
                         Pong = 0;
                         ThreadPool.QueueUserWorkItem((_) => StartPongTimer(PingTimeout));
                     }
                     else
                     {
                         OnClose("Ping timeout");
                     }
                 }
             });
         }, PingTimeout);
     });
 }
 private void StartUpgradeTimer(Action Callback)
 {
     SimpleMutex.Lock(CheckMutex, () => UpgradeTimer = new EngineIOTimeout(Callback, Server.Option.UpgradeTimeout));
 }