private void SetPing() { //var log = LogManager.GetLogger(Global.CallerName()); if (this.PingIntervalTimer != null) { PingIntervalTimer.Stop(); } var log = LogManager.GetLogger(Global.CallerName()); log.Info(string.Format("writing ping packet - expecting pong within {0}ms", PingTimeout)); PingIntervalTimer = EasyTimer.SetTimeout(() => { var log2 = LogManager.GetLogger(Global.CallerName()); log2.Info("EasyTimer SetPing start"); Ping(); OnHeartbeat(PingTimeout); log2.Info("EasyTimer SetPing finish"); }, (int)PingInterval); }
internal void OnHeartbeat(long timeout) { if (this.PingTimeoutTimer != null) { PingTimeoutTimer.Stop(); PingTimeoutTimer = null; } if (timeout <= 0) { timeout = this.PingInterval + this.PingTimeout; } PingTimeoutTimer = EasyTimer.SetTimeout(() => { var log2 = LogManager.GetLogger(Global.CallerName()); log2.Info("EasyTimer OnHeartbeat start"); if (ReadyState == ReadyStateEnum.CLOSED) { log2.Info("EasyTimer OnHeartbeat ReadyState == ReadyStateEnum.CLOSED finish"); return; } OnClose("ping timeout"); log2.Info("EasyTimer OnHeartbeat finish"); },(int) timeout); }