protected override void PostStop()
{
// All remaining messages in the buffer has to be delivered to dead letters. It is important to clear the sequence
// number otherwise deadLetters will ignore it to avoid reporting system messages as dead letters while they are
// still possibly retransmitted.
// Such a situation may arise when the EndpointWriter is shut down, and all of its mailbox contents are delivered
// to dead letters. These messages should be ignored, as they still live in resendBuffer and might be delivered to
// the remote system later.
foreach (var msg in _resendBuffer.Nacked.Concat(_resendBuffer.NonAcked))
{
Context.System.DeadLetters.Tell(msg.Copy(opt: null));
}
EndpointManager.ResendState value;
_receiveBuffers.TryRemove(new EndpointManager.Link(_localAddress, _remoteAddress), out value);
_autoResendTimer.Cancel();
_maxSilenceTimer?.Cancel();
}