mirror of
https://github.com/dotnet/MQTTnet.git
synced 2026-10-19 19:13:11 +08:00
Refactor code and update release notes
This commit is contained in:
@@ -1 +1,2 @@
|
|||||||
[Core] Fixed a memory leak in _AsyncSignal_ implementation (#1586, thanks to @mario-zelger).
|
[Core] Fixed a memory leak in _AsyncSignal_ implementation (#1586, thanks to @mario-zelger).
|
||||||
|
[Server] Fix not properly reset statistics (#1587, thanks to @damikun).
|
||||||
|
|||||||
@@ -240,6 +240,7 @@ See the LICENSE file in the project root for more information.</s:String>
|
|||||||
<s:Boolean x:Key="/Default/Environment/SettingsMigration/IsMigratorApplied/=JetBrains_002EReSharper_002EPsi_002ECSharp_002ECodeStyle_002ESettingsUpgrade_002ECSharpPlaceAttributeOnSameLineMigration/@EntryIndexedValue">True</s:Boolean>
|
<s:Boolean x:Key="/Default/Environment/SettingsMigration/IsMigratorApplied/=JetBrains_002EReSharper_002EPsi_002ECSharp_002ECodeStyle_002ESettingsUpgrade_002ECSharpPlaceAttributeOnSameLineMigration/@EntryIndexedValue">True</s:Boolean>
|
||||||
<s:Boolean x:Key="/Default/Environment/SettingsMigration/IsMigratorApplied/=JetBrains_002EReSharper_002EPsi_002ECSharp_002ECodeStyle_002ESettingsUpgrade_002EMigrateBlankLinesAroundFieldToBlankLinesAroundProperty/@EntryIndexedValue">True</s:Boolean>
|
<s:Boolean x:Key="/Default/Environment/SettingsMigration/IsMigratorApplied/=JetBrains_002EReSharper_002EPsi_002ECSharp_002ECodeStyle_002ESettingsUpgrade_002EMigrateBlankLinesAroundFieldToBlankLinesAroundProperty/@EntryIndexedValue">True</s:Boolean>
|
||||||
<s:Boolean x:Key="/Default/Environment/SettingsMigration/IsMigratorApplied/=JetBrains_002EReSharper_002EPsi_002ECSharp_002ECodeStyle_002ESettingsUpgrade_002EMigrateThisQualifierSettings/@EntryIndexedValue">True</s:Boolean>
|
<s:Boolean x:Key="/Default/Environment/SettingsMigration/IsMigratorApplied/=JetBrains_002EReSharper_002EPsi_002ECSharp_002ECodeStyle_002ESettingsUpgrade_002EMigrateThisQualifierSettings/@EntryIndexedValue">True</s:Boolean>
|
||||||
|
<s:Boolean x:Key="/Default/UserDictionary/Words/=CONNACK/@EntryIndexedValue">True</s:Boolean>
|
||||||
<s:Boolean x:Key="/Default/UserDictionary/Words/=PINGREQ/@EntryIndexedValue">True</s:Boolean>
|
<s:Boolean x:Key="/Default/UserDictionary/Words/=PINGREQ/@EntryIndexedValue">True</s:Boolean>
|
||||||
<s:Boolean x:Key="/Default/UserDictionary/Words/=PINGRESP/@EntryIndexedValue">True</s:Boolean>
|
<s:Boolean x:Key="/Default/UserDictionary/Words/=PINGRESP/@EntryIndexedValue">True</s:Boolean>
|
||||||
<s:Boolean x:Key="/Default/UserDictionary/Words/=PUBCOMP/@EntryIndexedValue">True</s:Boolean>
|
<s:Boolean x:Key="/Default/UserDictionary/Words/=PUBCOMP/@EntryIndexedValue">True</s:Boolean>
|
||||||
|
|||||||
@@ -10,15 +10,15 @@ namespace MQTTnet.Server
|
|||||||
{
|
{
|
||||||
public sealed class MqttClientStatistics
|
public sealed class MqttClientStatistics
|
||||||
{
|
{
|
||||||
|
long _receivedApplicationMessagesCount;
|
||||||
|
|
||||||
// Start with 1 because the CONNACK packet is not counted here.
|
// Start with 1 because the CONNACK packet is not counted here.
|
||||||
long _receivedPacketsCount = 1;
|
long _receivedPacketsCount = 1;
|
||||||
|
long _sentApplicationMessagesCount;
|
||||||
|
|
||||||
// Start with 1 because the CONNECT packet is not counted here.
|
// Start with 1 because the CONNECT packet is not counted here.
|
||||||
long _sentPacketsCount = 1;
|
long _sentPacketsCount = 1;
|
||||||
|
|
||||||
long _receivedApplicationMessagesCount;
|
|
||||||
long _sentApplicationMessagesCount;
|
|
||||||
|
|
||||||
public MqttClientStatistics()
|
public MqttClientStatistics()
|
||||||
{
|
{
|
||||||
ConnectedTimestamp = DateTime.UtcNow;
|
ConnectedTimestamp = DateTime.UtcNow;
|
||||||
@@ -28,36 +28,36 @@ namespace MQTTnet.Server
|
|||||||
|
|
||||||
LastNonKeepAlivePacketReceivedTimestamp = ConnectedTimestamp;
|
LastNonKeepAlivePacketReceivedTimestamp = ConnectedTimestamp;
|
||||||
}
|
}
|
||||||
|
|
||||||
public DateTime ConnectedTimestamp { get; }
|
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; }
|
public DateTime LastNonKeepAlivePacketReceivedTimestamp { get; private set; }
|
||||||
|
|
||||||
public long SentApplicationMessagesCount => Interlocked.Read(ref _sentApplicationMessagesCount);
|
/// <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 long ReceivedApplicationMessagesCount => Interlocked.Read(ref _receivedApplicationMessagesCount);
|
public long ReceivedApplicationMessagesCount => Interlocked.Read(ref _receivedApplicationMessagesCount);
|
||||||
|
|
||||||
public long SentPacketsCount => Interlocked.Read(ref _sentPacketsCount);
|
|
||||||
|
|
||||||
public long ReceivedPacketsCount => Interlocked.Read(ref _receivedPacketsCount);
|
public long ReceivedPacketsCount => Interlocked.Read(ref _receivedPacketsCount);
|
||||||
|
|
||||||
|
public long SentApplicationMessagesCount => Interlocked.Read(ref _sentApplicationMessagesCount);
|
||||||
|
|
||||||
|
public long SentPacketsCount => Interlocked.Read(ref _sentPacketsCount);
|
||||||
|
|
||||||
public void HandleReceivedPacket(MqttPacket packet)
|
public void HandleReceivedPacket(MqttPacket packet)
|
||||||
{
|
{
|
||||||
if (packet == null)
|
if (packet == null)
|
||||||
{
|
{
|
||||||
throw new ArgumentNullException(nameof(packet));
|
throw new ArgumentNullException(nameof(packet));
|
||||||
}
|
}
|
||||||
|
|
||||||
// This class is tracking all values from Clients perspective!
|
// This class is tracking all values from Clients perspective!
|
||||||
LastPacketSentTimestamp = DateTime.UtcNow;
|
LastPacketSentTimestamp = DateTime.UtcNow;
|
||||||
|
|
||||||
@@ -73,20 +73,14 @@ namespace MQTTnet.Server
|
|||||||
LastNonKeepAlivePacketReceivedTimestamp = LastPacketReceivedTimestamp;
|
LastNonKeepAlivePacketReceivedTimestamp = LastPacketReceivedTimestamp;
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
public void ResetStatistics(){
|
|
||||||
Interlocked.Exchange(ref _sentApplicationMessagesCount,0);
|
|
||||||
Interlocked.Exchange(ref _receivedApplicationMessagesCount,0);
|
|
||||||
Interlocked.Exchange(ref _sentPacketsCount,0);
|
|
||||||
Interlocked.Exchange(ref _receivedPacketsCount,0);
|
|
||||||
}
|
|
||||||
|
|
||||||
public void HandleSentPacket(MqttPacket packet)
|
public void HandleSentPacket(MqttPacket packet)
|
||||||
{
|
{
|
||||||
if (packet == null)
|
if (packet == null)
|
||||||
{
|
{
|
||||||
throw new ArgumentNullException(nameof(packet));
|
throw new ArgumentNullException(nameof(packet));
|
||||||
}
|
}
|
||||||
|
|
||||||
// This class is tracking all values from Clients perspective!
|
// This class is tracking all values from Clients perspective!
|
||||||
LastPacketReceivedTimestamp = DateTime.UtcNow;
|
LastPacketReceivedTimestamp = DateTime.UtcNow;
|
||||||
|
|
||||||
@@ -97,5 +91,13 @@ namespace MQTTnet.Server
|
|||||||
Interlocked.Increment(ref _receivedApplicationMessagesCount);
|
Interlocked.Increment(ref _receivedApplicationMessagesCount);
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
|
public void ResetStatistics()
|
||||||
|
{
|
||||||
|
Interlocked.Exchange(ref _sentApplicationMessagesCount, 0);
|
||||||
|
Interlocked.Exchange(ref _receivedApplicationMessagesCount, 0);
|
||||||
|
Interlocked.Exchange(ref _sentPacketsCount, 0);
|
||||||
|
Interlocked.Exchange(ref _receivedPacketsCount, 0);
|
||||||
|
}
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
Reference in New Issue
Block a user