mirror of
https://github.com/dotnet/MQTTnet.git
synced 2026-10-20 19:58:57 +08:00
Merge branch 'master' of https://github.com/chkr1011/MQTTnet into feature/Reason_Code_In_Subscription_Interceptor
# Conflicts: # Source/MQTTnet/Server/Internal/MqttClientConnectionStatistics.cs
This commit is contained in:
@@ -1,4 +1,4 @@
|
||||
using System;
|
||||
using System;
|
||||
using System.Threading;
|
||||
using MQTTnet.Packets;
|
||||
|
||||
@@ -24,11 +24,17 @@ namespace MQTTnet.Server
|
||||
|
||||
LastNonKeepAlivePacketReceivedTimestamp = ConnectedTimestamp;
|
||||
}
|
||||
|
||||
|
||||
public DateTime ConnectedTimestamp { get; }
|
||||
|
||||
/// <summary>
|
||||
/// Timestamp of the last package that has been sent to the client ("received" from the client's perspective)
|
||||
/// </summary>
|
||||
public DateTime LastPacketReceivedTimestamp { get; private set; }
|
||||
|
||||
|
||||
/// <summary>
|
||||
/// Timestamp of the last package that has been received from the client ("sent" from the client's perspective)
|
||||
/// </summary>
|
||||
public DateTime LastPacketSentTimestamp { get; private set; }
|
||||
|
||||
public DateTime LastNonKeepAlivePacketReceivedTimestamp { get; private set; }
|
||||
|
||||
@@ -1,4 +1,4 @@
|
||||
using System;
|
||||
using System;
|
||||
using System.Threading;
|
||||
using System.Threading.Tasks;
|
||||
using MQTTnet.Client;
|
||||
@@ -94,7 +94,7 @@ namespace MQTTnet.Server
|
||||
// If the client sends 1 sec. the server will allow up to 1.5 seconds.
|
||||
var maxDurationWithoutPacket = connection.KeepAlivePeriod * 1.5D;
|
||||
|
||||
var secondsWithoutPackage = (now - connection.Statistics.LastPacketReceivedTimestamp).TotalSeconds;
|
||||
var secondsWithoutPackage = (now - connection.Statistics.LastPacketSentTimestamp).TotalSeconds;
|
||||
if (secondsWithoutPackage < maxDurationWithoutPacket)
|
||||
{
|
||||
// A packet was received before the timeout is affected.
|
||||
|
||||
Reference in New Issue
Block a user