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

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

            _ = KeepAliveAsync(timer);

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