private void _Worker() { #if LOG4NET Logger.Socket.Debug("IdleWorkerThread started"); #endif try { while (_Connection.IsConnected) { if (_Connection.IsRegistered) { DateTime now = DateTime.Now; int last_ping_sent = (int)(now - _Connection._LastPingSent).TotalSeconds; int last_pong_rcvd = (int)(now - _Connection._LastPongReceived).TotalSeconds; // determins if the resoponse time is ok if (last_ping_sent < _Connection._PingTimeout) { // determines if it need to send another ping yet if (last_pong_rcvd > _Connection._PingInterval) { _Connection.WriteLine(Rfc2812.Ping(_Connection.Address), Priority.Critical); _Connection._LastPingSent = now; _Connection._LastPongReceived = now; } // else connection is fine, just continue } else { #if LOG4NET Logger.Socket.Warn("ping timeout, connection lost"); #endif _Connection.IsConnectionError = true; break; } } Thread.Sleep(_Connection._IdleWorkerInterval); } } catch (ThreadAbortException) { Thread.ResetAbort(); #if LOG4NET Logger.Socket.Debug("IdleWorkerThread aborted"); #endif } }
private void _Worker() { try { while (this._Connection.IsConnected) { Thread.Sleep(this._Connection._IdleWorkerInterval); if (this._Connection.IsRegistered) { DateTime now = DateTime.Now; int totalSeconds1 = (int)(now - this._Connection._LastPingSent).TotalSeconds; int totalSeconds2 = (int)(now - this._Connection._LastPongReceived).TotalSeconds; if (totalSeconds1 < this._Connection._PingTimeout) { if (!(this._Connection._LastPingSent > this._Connection._LastPongReceived) && totalSeconds2 > this._Connection._PingInterval) { this._Connection.WriteLine(Rfc2812.Ping(this._Connection.Address), Priority.Critical); this._Connection._LastPingSent = now; } } else { if (this._Connection.IsDisconnecting) { break; } this._Connection.IsConnectionError = true; break; } } } } catch (ThreadAbortException ex) { Thread.ResetAbort(); } catch (Exception ex) { } }
private void _Worker() { #if LOG4NET Logger.Socket.Debug("IdleWorkerThread started"); #endif try { while (_Connection.IsConnected) { Thread.Sleep(_Connection._IdleWorkerInterval); // only send active pings if we are registered if (!_Connection.IsRegistered) { continue; } DateTime now = DateTime.Now; int last_ping_sent = (int)(now - _Connection._LastPingSent).TotalSeconds; int last_pong_rcvd = (int)(now - _Connection._LastPongReceived).TotalSeconds; // determins if the resoponse time is ok if (last_ping_sent < _Connection._PingTimeout) { if (_Connection._LastPingSent > _Connection._LastPongReceived) { // there is a pending ping request, we have to wait continue; } // determines if it need to send another ping yet if (last_pong_rcvd > _Connection._PingInterval) { _Connection.WriteLine(Rfc2812.Ping(_Connection.Address), Priority.Critical); _Connection._LastPingSent = now; //_Connection._LastPongReceived = now; } // else connection is fine, just continue } else { if (_Connection.IsDisconnecting) { break; } #if LOG4NET Logger.Socket.Warn("ping timeout, connection lost"); #endif // only flag this as connection error if we are not // cleanly disconnecting _Connection.IsConnectionError = true; break; } } } catch (ThreadAbortException) { Thread.ResetAbort(); #if LOG4NET Logger.Socket.Debug("IdleWorkerThread aborted"); #endif } catch (Exception ex) { #if LOG4NET Logger.Socket.Error(ex); #endif } }
public void RfcPing(string server, string server2) => WriteLine(Rfc2812.Ping(server, server2));
public void RfcPing(string server, string server2, Priority priority) => WriteLine(Rfc2812.Ping(server, server2), priority);
public void RfcPing(string server) { this.WriteLine(Rfc2812.Ping(server)); }
public void RfcPing(string server, Priority priority) { this.WriteLine(Rfc2812.Ping(server), priority); }