Browse Source

Even more performance optimizations

release/3.x.x
Christian Kratky 7 years ago
parent
commit
6b1a6c054e
6 changed files with 14 additions and 11 deletions
  1. +1
    -1
      MQTTnet.Core/Packets/MqttConnAckPacket.cs
  2. +2
    -2
      MQTTnet.Core/Packets/MqttConnectPacket.cs
  3. +8
    -3
      MQTTnet.Core/Packets/MqttPublishPacket.cs
  4. +1
    -2
      MQTTnet.Core/Packets/MqttSubAckPacket.cs
  5. +1
    -2
      MQTTnet.Core/Packets/MqttSubscribePacket.cs
  6. +1
    -1
      MQTTnet.Core/Server/MqttClientSession.cs

+ 1
- 1
MQTTnet.Core/Packets/MqttConnAckPacket.cs View File

@@ -10,7 +10,7 @@ namespace MQTTnet.Core.Packets


public override string ToString() public override string ToString()
{ {
return $"{nameof(MqttConnAckPacket)}: [ConnectReturnCode={ConnectReturnCode}] [IsSessionPresent={IsSessionPresent}]";
return nameof(MqttConnAckPacket) + ": [ConnectReturnCode=" + ConnectReturnCode + "] [IsSessionPresent=" + IsSessionPresent + "]";
} }
} }
} }

+ 2
- 2
MQTTnet.Core/Packets/MqttConnectPacket.cs View File

@@ -2,7 +2,7 @@


namespace MQTTnet.Core.Packets namespace MQTTnet.Core.Packets
{ {
public sealed class MqttConnectPacket: MqttBasePacket
public sealed class MqttConnectPacket : MqttBasePacket
{ {
public MqttProtocolVersion ProtocolVersion { get; set; } public MqttProtocolVersion ProtocolVersion { get; set; }


@@ -20,7 +20,7 @@ namespace MQTTnet.Core.Packets


public override string ToString() public override string ToString()
{ {
return $"{nameof(MqttConnectPacket)} [ClientId={ClientId}] [Username={Username}] [Password={Password}] [KeepAlivePeriod={KeepAlivePeriod}] [CleanSession={CleanSession}]";
return nameof(MqttConnectPacket) + ": [ClientId=" + ClientId + "] [Username=" + Username + "] [Password=" + Password + "] [KeepAlivePeriod=" + KeepAlivePeriod + "] [CleanSession=" + CleanSession + "]";
} }
} }
} }

+ 8
- 3
MQTTnet.Core/Packets/MqttPublishPacket.cs View File

@@ -1,4 +1,4 @@
using System.Text;
using System;
using MQTTnet.Core.Protocol; using MQTTnet.Core.Protocol;


namespace MQTTnet.Core.Packets namespace MQTTnet.Core.Packets
@@ -17,8 +17,13 @@ namespace MQTTnet.Core.Packets


public override string ToString() public override string ToString()
{ {
return
$"{nameof(MqttPublishPacket)} [Topic={Topic}] [Payload={Encoding.UTF8.GetString(Payload, 0, Payload.Length)}] [QoSLevel={QualityOfServiceLevel}] [Dup={Dup}] [Retain={Retain}] [PacketIdentifier={PacketIdentifier}]";
return nameof(MqttPublishPacket) +
": [Topic=" + Topic + "]" +
" [Payload=" + Convert.ToBase64String(Payload) + "]" +
" [QoSLevel=" + QualityOfServiceLevel + "]" +
" [Dup=" + Dup + "]" +
" [Retain=" + Retain + "]" +
" [PacketIdentifier=" + PacketIdentifier + "]";
} }
} }
} }

+ 1
- 2
MQTTnet.Core/Packets/MqttSubAckPacket.cs View File

@@ -13,8 +13,7 @@ namespace MQTTnet.Core.Packets
public override string ToString() public override string ToString()
{ {
var subscribeReturnCodesText = string.Join(",", SubscribeReturnCodes.Select(f => f.ToString())); var subscribeReturnCodesText = string.Join(",", SubscribeReturnCodes.Select(f => f.ToString()));
return
$"{nameof(MqttSubAckPacket)} [PacketIdentifier={PacketIdentifier}] [SubscribeReturnCodes={subscribeReturnCodesText}]";
return nameof(MqttSubAckPacket) + ": [PacketIdentifier=" + PacketIdentifier + "] [SubscribeReturnCodes=" + subscribeReturnCodesText + "]";
} }
} }
} }

+ 1
- 2
MQTTnet.Core/Packets/MqttSubscribePacket.cs View File

@@ -12,8 +12,7 @@ namespace MQTTnet.Core.Packets
public override string ToString() public override string ToString()
{ {
var topicFiltersText = string.Join(",", TopicFilters.Select(f => $"{f.Topic}@{f.QualityOfServiceLevel}")); var topicFiltersText = string.Join(",", TopicFilters.Select(f => $"{f.Topic}@{f.QualityOfServiceLevel}"));
return
$"{nameof(MqttSubscribePacket)} [PacketIdentifier={PacketIdentifier}] [TopicFilters={topicFiltersText}]";
return nameof(MqttSubscribePacket) + ": [PacketIdentifier=" + PacketIdentifier + "] [TopicFilters=" + topicFiltersText + "]";
} }
} }
} }

+ 1
- 1
MQTTnet.Core/Server/MqttClientSession.cs View File

@@ -76,7 +76,7 @@ namespace MQTTnet.Core.Server
_cancellationTokenSource.Cancel(); _cancellationTokenSource.Cancel();
Adapter = null; Adapter = null;


MqttTrace.Information(nameof(MqttClientSession), $"Client '{_identifier}': Disconnected.");
MqttTrace.Information(nameof(MqttClientSession), "Client '{0}': Disconnected.", _identifier);
} }
} }




Loading…
Cancel
Save