private TimerAwaitable StartKeepAliveTimer() { Log.StartingKeepAliveTimer(_logger, DefaultKeepAliveInterval); _lastReceiveTimestamp = Stopwatch.GetTimestamp(); var timer = new TimerAwaitable(DefaultKeepAliveInterval, DefaultKeepAliveInterval); _ = KeepAliveAsync(timer); return(timer); }
private async Task KeepAliveAsync(TimerAwaitable timer) { using (timer) { timer.Start(); while (await timer) { if (Stopwatch.GetTimestamp() - Interlocked.Read(ref _lastReceiveTimestamp) > DefaultServiceTimeoutTicks) { AbortConnection(); // We shouldn't get here twice. continue; } } } }
public HeartBeat(IClientConnectionManager connectionManager) { _connectionManager = connectionManager; _nextHeartbeat = new TimerAwaitable(_heartbeatTickRate, _heartbeatTickRate); }