mirror of
https://github.com/dotnet/MQTTnet.git
synced 2026-10-16 01:03:01 +08:00
Reset the keep alive monitor if a session is being resumed from a different (or same) client.
This commit is contained in:
@@ -50,6 +50,12 @@ namespace MQTTnet.Server
|
||||
_isPaused = false;
|
||||
}
|
||||
|
||||
public void Reset()
|
||||
{
|
||||
_lastPacketReceivedTracker.Restart();
|
||||
_lastNonKeepAlivePacketReceivedTracker.Restart();
|
||||
}
|
||||
|
||||
public void PacketReceived(MqttBasePacket packet)
|
||||
{
|
||||
_lastPacketReceivedTracker.Restart();
|
||||
|
||||
@@ -56,6 +56,11 @@ namespace MQTTnet.Server
|
||||
|
||||
public string ClientId { get; }
|
||||
|
||||
public void ResumeSession()
|
||||
{
|
||||
_keepAliveMonitor.Reset();
|
||||
}
|
||||
|
||||
public void FillStatus(MqttClientSessionStatus status)
|
||||
{
|
||||
status.ClientId = ClientId;
|
||||
@@ -87,11 +92,11 @@ namespace MQTTnet.Server
|
||||
|
||||
_cancellationTokenSource = new CancellationTokenSource();
|
||||
|
||||
//woraround for https://github.com/dotnet/corefx/issues/24430
|
||||
//workaround for https://github.com/dotnet/corefx/issues/24430
|
||||
#pragma warning disable 4014
|
||||
_cleanupHandle = _cancellationTokenSource.Token.Register(() => CleanupAsync());
|
||||
#pragma warning restore 4014
|
||||
//endworkaround
|
||||
//end workaround
|
||||
|
||||
_wasCleanDisconnect = false;
|
||||
_willMessage = connectPacket.WillMessage;
|
||||
|
||||
@@ -312,6 +312,8 @@ namespace MQTTnet.Server
|
||||
}
|
||||
else
|
||||
{
|
||||
clientSession.ResumeSession();
|
||||
|
||||
_logger.Verbose("Reusing existing session of client '{0}'.", connectPacket.ClientId);
|
||||
}
|
||||
}
|
||||
|
||||
Reference in New Issue
Block a user