Esempio n. 1
0
        private TimerAwaitable StartKeepAliveTimer()
        {
            Log.StartingKeepAliveTimer(_logger, DefaultKeepAliveInterval);

            _lastReceiveTimestamp = Stopwatch.GetTimestamp();
            var timer = new TimerAwaitable(DefaultKeepAliveInterval, DefaultKeepAliveInterval);

            _ = KeepAliveAsync(timer);

            return(timer);
        }
Esempio n. 2
0
        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;
                    }
                }
            }
        }
Esempio n. 3
0
 public HeartBeat(IClientConnectionManager connectionManager)
 {
     _connectionManager = connectionManager;
     _nextHeartbeat     = new TimerAwaitable(_heartbeatTickRate, _heartbeatTickRate);
 }