static void OnHeartBeatTimer()

in src/AmqpConnection.cs [762:802]


                static void OnHeartBeatTimer(object state)
                {
                    TimedHeartBeat thisPtr = (TimedHeartBeat)state;
                    if (thisPtr.connection.IsClosing())
                    {
                        return;
                    }

                    DateTime now = DateTime.UtcNow;

                    try
                    {
                        if (thisPtr.localInterval < uint.MaxValue &&
                            now.Subtract(thisPtr.lastReceiveTime).TotalMilliseconds > thisPtr.localInterval)
                        {
                            string message = AmqpResources.GetString(AmqpResources.AmqpConnectionInactive,
                                thisPtr.localInterval, thisPtr.connection.Settings.ContainerId);
                            var amqpException = new AmqpException(AmqpErrorCode.ConnectionForced, message);
                            AmqpTrace.Provider.AmqpLogError(thisPtr.connection, "OnHeartBeatTimer", amqpException);
                            thisPtr.connection.SafeClose(amqpException);

                            return;
                        }

                        if (thisPtr.remoteInterval < uint.MaxValue &&
                            now.Subtract(thisPtr.lastSendTime).TotalMilliseconds >= thisPtr.remoteInterval)
                        {
                            thisPtr.connection.SendCommand(null, 0, (ByteBuffer)null);
                        }

                        thisPtr.heartBeatTimer.Change(thisPtr.GetTimerInterval(now), Timeout.InfiniteTimeSpan);
                    }
                    catch (Exception exception) when (!Fx.IsFatal(exception))
                    {
                        if (!thisPtr.connection.IsClosing())
                        {
                            AmqpTrace.Provider.AmqpLogError(thisPtr.connection, "OnHeartBeatTimer", exception);
                            thisPtr.connection.SafeClose(exception);
                        }
                    }
                }