improved behavior when multiple connections fight over a session

This commit is contained in:
JanEggers
2020-10-11 16:41:13 +02:00
parent f259bbcc9b
commit f7db00c08e
4 changed files with 76 additions and 22 deletions
@@ -257,6 +257,15 @@ namespace MQTTnet.Server
Session.WillMessage = null;
}
if (_isTakeover)
{
// dont use SendAsync here _cancellationToken is already cancelled
await _channelAdapter.SendPacketAsync(new MqttDisconnectPacket()
{
ReasonCode = MqttDisconnectReasonCode.SessionTakenOver
}, TimeSpan.Zero, CancellationToken.None).ConfigureAwait(false);
}
_packetDispatcher.Reset();
_channelAdapter.ReadingPacketStartedCallback = null;