Browse Source

Add support for extended authentication exchange.

release/3.x.x
Christian Kratky 5 years ago
parent
commit
396f040aae
29 changed files with 289 additions and 57 deletions
  1. +1
    -0
      Build/MQTTnet.nuspec
  2. +9
    -0
      Source/MQTTnet/Client/ExtendedAuthenticationExchange/IMqttExtendedAuthenticationExchangeHandler.cs
  3. +35
    -0
      Source/MQTTnet/Client/ExtendedAuthenticationExchange/MqttExtendedAuthenticationExchangeContext.cs
  4. +17
    -0
      Source/MQTTnet/Client/ExtendedAuthenticationExchange/MqttExtendedAuthenticationExchangeData.cs
  5. +2
    -0
      Source/MQTTnet/Client/IMqttClient.cs
  6. +26
    -0
      Source/MQTTnet/Client/MqttClient.cs
  7. +16
    -0
      Source/MQTTnet/Client/MqttClientExtensions.cs
  8. +2
    -0
      Source/MQTTnet/Client/Options/IMqttClientOptions.cs
  9. +2
    -0
      Source/MQTTnet/Client/Options/MqttClientOptions.cs
  10. +7
    -0
      Source/MQTTnet/Client/Options/MqttClientOptionsBuilder.cs
  11. +9
    -5
      Source/MQTTnet/Formatter/V3/MqttV310PacketFormatter.cs
  12. +2
    -2
      Source/MQTTnet/Formatter/V5/MqttV500DataConverter.cs
  13. +145
    -34
      Source/MQTTnet/Formatter/V5/MqttV500PacketDecoder.cs
  14. +1
    -1
      Source/MQTTnet/Packets/MqttAuthPacketProperties.cs
  15. +1
    -1
      Source/MQTTnet/Packets/MqttConnAckPacketProperties.cs
  16. +1
    -1
      Source/MQTTnet/Packets/MqttConnectPacketProperties.cs
  17. +1
    -1
      Source/MQTTnet/Packets/MqttDisconnectPacketProperties.cs
  18. +1
    -1
      Source/MQTTnet/Packets/MqttPubAckPacketProperties.cs
  19. +1
    -1
      Source/MQTTnet/Packets/MqttPubCompPacketProperties.cs
  20. +1
    -1
      Source/MQTTnet/Packets/MqttPubRecPacketProperties.cs
  21. +1
    -1
      Source/MQTTnet/Packets/MqttPubRelPacketProperties.cs
  22. +1
    -1
      Source/MQTTnet/Packets/MqttSubAckPacket.cs
  23. +1
    -1
      Source/MQTTnet/Packets/MqttSubAckPacketProperties.cs
  24. +1
    -1
      Source/MQTTnet/Packets/MqttSubscribePacket.cs
  25. +1
    -1
      Source/MQTTnet/Packets/MqttSubscribePacketProperties.cs
  26. +1
    -1
      Source/MQTTnet/Packets/MqttUnsubAckPacket.cs
  27. +1
    -1
      Source/MQTTnet/Packets/MqttUnsubAckPacketProperties.cs
  28. +1
    -1
      Source/MQTTnet/Packets/MqttUnsubscribePacket.cs
  29. +1
    -1
      Source/MQTTnet/Packets/MqttUnsubscribePacketProperties.cs

+ 1
- 0
Build/MQTTnet.nuspec View File

@@ -12,6 +12,7 @@
<description>MQTTnet is a high performance .NET library for MQTT based communication. It provides a MQTT client and a MQTT server (broker).</description> <description>MQTTnet is a high performance .NET library for MQTT based communication. It provides a MQTT client and a MQTT server (broker).</description>
<releaseNotes> <releaseNotes>
* [Core] Fixed issues in MQTTv5 message encoding and decoding. * [Core] Fixed issues in MQTTv5 message encoding and decoding.
* [Client] Added support for extended authentication exchange.
</releaseNotes> </releaseNotes>
<copyright>Copyright Christian Kratky 2016-2019</copyright> <copyright>Copyright Christian Kratky 2016-2019</copyright>
<tags>MQTT Message Queue Telemetry Transport MQTTClient MQTTServer Server MQTTBroker Broker NETStandard IoT InternetOfThings Messaging Hardware Arduino Sensor Actuator M2M ESP Smart Home Cities Automation Xamarin</tags> <tags>MQTT Message Queue Telemetry Transport MQTTClient MQTTServer Server MQTTBroker Broker NETStandard IoT InternetOfThings Messaging Hardware Arduino Sensor Actuator M2M ESP Smart Home Cities Automation Xamarin</tags>


+ 9
- 0
Source/MQTTnet/Client/ExtendedAuthenticationExchange/IMqttExtendedAuthenticationExchangeHandler.cs View File

@@ -0,0 +1,9 @@
using System.Threading.Tasks;

namespace MQTTnet.Client.ExtendedAuthenticationExchange
{
public interface IMqttExtendedAuthenticationExchangeHandler
{
Task HandleRequestAsync(MqttExtendedAuthenticationExchangeContext context);
}
}

+ 35
- 0
Source/MQTTnet/Client/ExtendedAuthenticationExchange/MqttExtendedAuthenticationExchangeContext.cs View File

@@ -0,0 +1,35 @@
using System;
using System.Collections.Generic;
using MQTTnet.Packets;
using MQTTnet.Protocol;

namespace MQTTnet.Client.ExtendedAuthenticationExchange
{
public class MqttExtendedAuthenticationExchangeContext
{
public MqttExtendedAuthenticationExchangeContext(MqttAuthPacket authPacket, IMqttClient client)
{
if (authPacket == null) throw new ArgumentNullException(nameof(authPacket));

ReasonCode = authPacket.ReasonCode;
ReasonString = authPacket.Properties?.ReasonString;
AuthenticationMethod = authPacket.Properties?.AuthenticationMethod;
AuthenticationData = authPacket.Properties?.AuthenticationData;
UserProperties = authPacket.Properties?.UserProperties;

Client = client ?? throw new ArgumentNullException(nameof(client));
}

public MqttAuthenticateReasonCode ReasonCode { get; }

public string ReasonString { get; }

public string AuthenticationMethod { get; }

public byte[] AuthenticationData { get; }

public List<MqttUserProperty> UserProperties { get; }

public IMqttClient Client { get; }
}
}

+ 17
- 0
Source/MQTTnet/Client/ExtendedAuthenticationExchange/MqttExtendedAuthenticationExchangeData.cs View File

@@ -0,0 +1,17 @@
using System.Collections.Generic;
using MQTTnet.Packets;
using MQTTnet.Protocol;

namespace MQTTnet.Client.ExtendedAuthenticationExchange
{
public class MqttExtendedAuthenticationExchangeData
{
public MqttAuthenticateReasonCode ReasonCode { get; set; }

public string ReasonString { get; set; }

public byte[] AuthenticationData { get; set; }

public List<MqttUserProperty> UserProperties { get; }
}
}

+ 2
- 0
Source/MQTTnet/Client/IMqttClient.cs View File

@@ -3,6 +3,7 @@ using System.Threading;
using System.Threading.Tasks; using System.Threading.Tasks;
using MQTTnet.Client.Connecting; using MQTTnet.Client.Connecting;
using MQTTnet.Client.Disconnecting; using MQTTnet.Client.Disconnecting;
using MQTTnet.Client.ExtendedAuthenticationExchange;
using MQTTnet.Client.Options; using MQTTnet.Client.Options;
using MQTTnet.Client.Subscribing; using MQTTnet.Client.Subscribing;
using MQTTnet.Client.Unsubscribing; using MQTTnet.Client.Unsubscribing;
@@ -21,6 +22,7 @@ namespace MQTTnet.Client
Task<MqttClientAuthenticateResult> ConnectAsync(IMqttClientOptions options, CancellationToken cancellationToken); Task<MqttClientAuthenticateResult> ConnectAsync(IMqttClientOptions options, CancellationToken cancellationToken);
Task DisconnectAsync(MqttClientDisconnectOptions options, CancellationToken cancellationToken); Task DisconnectAsync(MqttClientDisconnectOptions options, CancellationToken cancellationToken);


Task SendExtendedAuthenticationExchangeDataAsync(MqttExtendedAuthenticationExchangeData data, CancellationToken cancellationToken);
Task<MqttClientSubscribeResult> SubscribeAsync(MqttClientSubscribeOptions options, CancellationToken cancellationToken); Task<MqttClientSubscribeResult> SubscribeAsync(MqttClientSubscribeOptions options, CancellationToken cancellationToken);
Task<MqttClientUnsubscribeResult> UnsubscribeAsync(MqttClientUnsubscribeOptions options, CancellationToken cancellationToken); Task<MqttClientUnsubscribeResult> UnsubscribeAsync(MqttClientUnsubscribeOptions options, CancellationToken cancellationToken);
} }

+ 26
- 0
Source/MQTTnet/Client/MqttClient.cs View File

@@ -5,6 +5,7 @@ using System.Threading.Tasks;
using MQTTnet.Adapter; using MQTTnet.Adapter;
using MQTTnet.Client.Connecting; using MQTTnet.Client.Connecting;
using MQTTnet.Client.Disconnecting; using MQTTnet.Client.Disconnecting;
using MQTTnet.Client.ExtendedAuthenticationExchange;
using MQTTnet.Client.Options; using MQTTnet.Client.Options;
using MQTTnet.Client.Publishing; using MQTTnet.Client.Publishing;
using MQTTnet.Client.Receiving; using MQTTnet.Client.Receiving;
@@ -138,6 +139,23 @@ namespace MQTTnet.Client
} }
} }


public Task SendExtendedAuthenticationExchangeDataAsync(MqttExtendedAuthenticationExchangeData data, CancellationToken cancellationToken)
{
if (data == null) throw new ArgumentNullException(nameof(data));

return SendAsync(new MqttAuthPacket
{
Properties = new MqttAuthPacketProperties
{
// This must always be equal to the value from the CONNECT packet. So we use it here to ensure that.
AuthenticationMethod = Options.AuthenticationMethod,
AuthenticationData = data.AuthenticationData,
ReasonString = data.ReasonString,
UserProperties = data.UserProperties
}
}, cancellationToken);
}

public async Task<MqttClientSubscribeResult> SubscribeAsync(MqttClientSubscribeOptions options, CancellationToken cancellationToken) public async Task<MqttClientSubscribeResult> SubscribeAsync(MqttClientSubscribeOptions options, CancellationToken cancellationToken)
{ {
if (options == null) throw new ArgumentNullException(nameof(options)); if (options == null) throw new ArgumentNullException(nameof(options));
@@ -474,6 +492,14 @@ namespace MQTTnet.Client


await DisconnectAsync(null, cancellationToken).ConfigureAwait(false); await DisconnectAsync(null, cancellationToken).ConfigureAwait(false);
} }
else if (packet is MqttAuthPacket authPacket)
{
var extendedAuthenticationExchangeHandler = Options.ExtendedAuthenticationExchangeHandler;
if (extendedAuthenticationExchangeHandler != null)
{
await extendedAuthenticationExchangeHandler.HandleRequestAsync(new MqttExtendedAuthenticationExchangeContext(authPacket, this)).ConfigureAwait(false);
}
}
else else
{ {
_packetDispatcher.Dispatch(packet); _packetDispatcher.Dispatch(packet);


+ 16
- 0
Source/MQTTnet/Client/MqttClientExtensions.cs View File

@@ -4,6 +4,7 @@ using System.Threading;
using System.Threading.Tasks; using System.Threading.Tasks;
using MQTTnet.Client.Connecting; using MQTTnet.Client.Connecting;
using MQTTnet.Client.Disconnecting; using MQTTnet.Client.Disconnecting;
using MQTTnet.Client.ExtendedAuthenticationExchange;
using MQTTnet.Client.Options; using MQTTnet.Client.Options;
using MQTTnet.Client.Publishing; using MQTTnet.Client.Publishing;
using MQTTnet.Client.Receiving; using MQTTnet.Client.Receiving;
@@ -170,21 +171,36 @@ namespace MQTTnet.Client


public static Task<MqttClientAuthenticateResult> ConnectAsync(this IMqttClient client, IMqttClientOptions options) public static Task<MqttClientAuthenticateResult> ConnectAsync(this IMqttClient client, IMqttClientOptions options)
{ {
if (client == null) throw new ArgumentNullException(nameof(client));

return client.ConnectAsync(options, CancellationToken.None); return client.ConnectAsync(options, CancellationToken.None);
} }


public static Task DisconnectAsync(this IMqttClient client, MqttClientDisconnectOptions options) public static Task DisconnectAsync(this IMqttClient client, MqttClientDisconnectOptions options)
{ {
if (client == null) throw new ArgumentNullException(nameof(client));

return client.DisconnectAsync(options, CancellationToken.None); return client.DisconnectAsync(options, CancellationToken.None);
} }


public static Task SendExtendedAuthenticationExchangeDataAsync(this IMqttClient client, MqttExtendedAuthenticationExchangeData data)
{
if (client == null) throw new ArgumentNullException(nameof(client));

return client.SendExtendedAuthenticationExchangeDataAsync(data, CancellationToken.None);
}

public static Task<MqttClientSubscribeResult> SubscribeAsync(this IMqttClient client, MqttClientSubscribeOptions options) public static Task<MqttClientSubscribeResult> SubscribeAsync(this IMqttClient client, MqttClientSubscribeOptions options)
{ {
if (client == null) throw new ArgumentNullException(nameof(client));

return client.SubscribeAsync(options, CancellationToken.None); return client.SubscribeAsync(options, CancellationToken.None);
} }


public static Task<MqttClientUnsubscribeResult> UnsubscribeAsync(this IMqttClient client, MqttClientUnsubscribeOptions options) public static Task<MqttClientUnsubscribeResult> UnsubscribeAsync(this IMqttClient client, MqttClientUnsubscribeOptions options)
{ {
if (client == null) throw new ArgumentNullException(nameof(client));

return client.UnsubscribeAsync(options, CancellationToken.None); return client.UnsubscribeAsync(options, CancellationToken.None);
} }




+ 2
- 0
Source/MQTTnet/Client/Options/IMqttClientOptions.cs View File

@@ -1,4 +1,5 @@
using System; using System;
using MQTTnet.Client.ExtendedAuthenticationExchange;
using MQTTnet.Formatter; using MQTTnet.Formatter;


namespace MQTTnet.Client.Options namespace MQTTnet.Client.Options
@@ -8,6 +9,7 @@ namespace MQTTnet.Client.Options
string ClientId { get; } string ClientId { get; }
bool CleanSession { get; } bool CleanSession { get; }
IMqttClientCredentials Credentials { get; } IMqttClientCredentials Credentials { get; }
IMqttExtendedAuthenticationExchangeHandler ExtendedAuthenticationExchangeHandler { get; }
MqttProtocolVersion ProtocolVersion { get; } MqttProtocolVersion ProtocolVersion { get; }
IMqttClientChannelOptions ChannelOptions { get; } IMqttClientChannelOptions ChannelOptions { get; }


+ 2
- 0
Source/MQTTnet/Client/Options/MqttClientOptions.cs View File

@@ -1,4 +1,5 @@
using System; using System;
using MQTTnet.Client.ExtendedAuthenticationExchange;
using MQTTnet.Formatter; using MQTTnet.Formatter;


namespace MQTTnet.Client.Options namespace MQTTnet.Client.Options
@@ -8,6 +9,7 @@ namespace MQTTnet.Client.Options
public string ClientId { get; set; } = Guid.NewGuid().ToString("N"); public string ClientId { get; set; } = Guid.NewGuid().ToString("N");
public bool CleanSession { get; set; } = true; public bool CleanSession { get; set; } = true;
public IMqttClientCredentials Credentials { get; set; } public IMqttClientCredentials Credentials { get; set; }
public IMqttExtendedAuthenticationExchangeHandler ExtendedAuthenticationExchangeHandler { get; set; }
public MqttProtocolVersion ProtocolVersion { get; set; } = MqttProtocolVersion.V311; public MqttProtocolVersion ProtocolVersion { get; set; } = MqttProtocolVersion.V311;


public IMqttClientChannelOptions ChannelOptions { get; set; } public IMqttClientChannelOptions ChannelOptions { get; set; }


+ 7
- 0
Source/MQTTnet/Client/Options/MqttClientOptionsBuilder.cs View File

@@ -1,5 +1,6 @@
using System; using System;
using System.Linq; using System.Linq;
using MQTTnet.Client.ExtendedAuthenticationExchange;
using MQTTnet.Formatter; using MQTTnet.Formatter;


namespace MQTTnet.Client.Options namespace MQTTnet.Client.Options
@@ -125,6 +126,12 @@ namespace MQTTnet.Client.Options
return this; return this;
} }


public MqttClientOptionsBuilder WithExtendedAuthenticationExchangeHandler(IMqttExtendedAuthenticationExchangeHandler handler)
{
_options.ExtendedAuthenticationExchangeHandler = handler;
return this;
}

public MqttClientOptionsBuilder WithTcpServer(string server, int? port = null) public MqttClientOptionsBuilder WithTcpServer(string server, int? port = null)
{ {
_tcpOptions = new MqttClientTcpOptions _tcpOptions = new MqttClientTcpOptions


+ 9
- 5
Source/MQTTnet/Formatter/V3/MqttV310PacketFormatter.cs View File

@@ -10,7 +10,11 @@ namespace MQTTnet.Formatter.V3
public class MqttV310PacketFormatter : IMqttPacketFormatter public class MqttV310PacketFormatter : IMqttPacketFormatter
{ {
private const int FixedHeaderSize = 1; private const int FixedHeaderSize = 1;

private static readonly MqttPingReqPacket PingReqPacket = new MqttPingReqPacket();
private static readonly MqttPingRespPacket PingRespPacket = new MqttPingRespPacket();
private static readonly MqttDisconnectPacket DisconnectPacket = new MqttDisconnectPacket();

private readonly IMqttPacketWriter _packetWriter; private readonly IMqttPacketWriter _packetWriter;


public MqttV310PacketFormatter() public MqttV310PacketFormatter()
@@ -67,14 +71,14 @@ namespace MQTTnet.Formatter.V3
{ {
case MqttControlPacketType.Connect: return DecodeConnectPacket(receivedMqttPacket.Body); case MqttControlPacketType.Connect: return DecodeConnectPacket(receivedMqttPacket.Body);
case MqttControlPacketType.ConnAck: return DecodeConnAckPacket(receivedMqttPacket.Body); case MqttControlPacketType.ConnAck: return DecodeConnAckPacket(receivedMqttPacket.Body);
case MqttControlPacketType.Disconnect: return new MqttDisconnectPacket();
case MqttControlPacketType.Disconnect: return DisconnectPacket;
case MqttControlPacketType.Publish: return DecodePublishPacket(receivedMqttPacket); case MqttControlPacketType.Publish: return DecodePublishPacket(receivedMqttPacket);
case MqttControlPacketType.PubAck: return DecodePubAckPacket(receivedMqttPacket.Body); case MqttControlPacketType.PubAck: return DecodePubAckPacket(receivedMqttPacket.Body);
case MqttControlPacketType.PubRec: return DecodePubRecPacket(receivedMqttPacket.Body); case MqttControlPacketType.PubRec: return DecodePubRecPacket(receivedMqttPacket.Body);
case MqttControlPacketType.PubRel: return DecodePubRelPacket(receivedMqttPacket.Body); case MqttControlPacketType.PubRel: return DecodePubRelPacket(receivedMqttPacket.Body);
case MqttControlPacketType.PubComp: return DecodePubCompPacket(receivedMqttPacket.Body); case MqttControlPacketType.PubComp: return DecodePubCompPacket(receivedMqttPacket.Body);
case MqttControlPacketType.PingReq: return new MqttPingReqPacket();
case MqttControlPacketType.PingResp: return new MqttPingRespPacket();
case MqttControlPacketType.PingReq: return PingReqPacket;
case MqttControlPacketType.PingResp: return PingRespPacket;
case MqttControlPacketType.Subscribe: return DecodeSubscribePacket(receivedMqttPacket.Body); case MqttControlPacketType.Subscribe: return DecodeSubscribePacket(receivedMqttPacket.Body);
case MqttControlPacketType.SubAck: return DecodeSubAckPacket(receivedMqttPacket.Body); case MqttControlPacketType.SubAck: return DecodeSubAckPacket(receivedMqttPacket.Body);
case MqttControlPacketType.Unsubscibe: return DecodeUnsubscribePacket(receivedMqttPacket.Body); case MqttControlPacketType.Unsubscibe: return DecodeUnsubscribePacket(receivedMqttPacket.Body);
@@ -229,7 +233,7 @@ namespace MQTTnet.Formatter.V3


if (!receivedMqttPacket.Body.EndOfStream) if (!receivedMqttPacket.Body.EndOfStream)
{ {
packet.Payload = receivedMqttPacket.Body.ReadRemainingData().ToArray();
packet.Payload = receivedMqttPacket.Body.ReadRemainingData();
} }


return packet; return packet;


+ 2
- 2
Source/MQTTnet/Formatter/V5/MqttV500DataConverter.cs View File

@@ -160,7 +160,7 @@ namespace MQTTnet.Formatter.V5


packet.TopicFilters.AddRange(options.TopicFilters); packet.TopicFilters.AddRange(options.TopicFilters);
packet.Properties.SubscriptionIdentifier = options.SubscriptionIdentifier; packet.Properties.SubscriptionIdentifier = options.SubscriptionIdentifier;
packet.Properties.UserProperties.AddRange(options.UserProperties);
packet.Properties.UserProperties = options.UserProperties;


return packet; return packet;
} }
@@ -175,7 +175,7 @@ namespace MQTTnet.Formatter.V5
}; };


packet.TopicFilters.AddRange(options.TopicFilters); packet.TopicFilters.AddRange(options.TopicFilters);
packet.Properties.UserProperties.AddRange(options.UserProperties);
packet.Properties.UserProperties = options.UserProperties;


return packet; return packet;
} }


+ 145
- 34
Source/MQTTnet/Formatter/V5/MqttV500PacketDecoder.cs View File

@@ -1,6 +1,5 @@
using System; using System;
using System.Collections.Generic; using System.Collections.Generic;
using System.Linq;
using MQTTnet.Adapter; using MQTTnet.Adapter;
using MQTTnet.Exceptions; using MQTTnet.Exceptions;
using MQTTnet.Packets; using MQTTnet.Packets;
@@ -10,6 +9,10 @@ namespace MQTTnet.Formatter.V5
{ {
public class MqttV500PacketDecoder public class MqttV500PacketDecoder
{ {
private static readonly MqttPingReqPacket PingReqPacket = new MqttPingReqPacket();

private static readonly MqttPingRespPacket PingRespPacket = new MqttPingRespPacket();

public MqttBasePacket Decode(ReceivedMqttPacket receivedMqttPacket) public MqttBasePacket Decode(ReceivedMqttPacket receivedMqttPacket)
{ {
if (receivedMqttPacket == null) throw new ArgumentNullException(nameof(receivedMqttPacket)); if (receivedMqttPacket == null) throw new ArgumentNullException(nameof(receivedMqttPacket));
@@ -46,10 +49,7 @@ namespace MQTTnet.Formatter.V5
{ {
ThrowIfBodyIsEmpty(body); ThrowIfBodyIsEmpty(body);


var packet = new MqttConnectPacket
{
Properties = new MqttConnectPacketProperties()
};
var packet = new MqttConnectPacket();


var protocolName = body.ReadStringWithLengthPrefix(); var protocolName = body.ReadStringWithLengthPrefix();
var protocolVersion = body.ReadByte(); var protocolVersion = body.ReadByte();
@@ -84,6 +84,11 @@ namespace MQTTnet.Formatter.V5
var propertiesReader = new MqttV500PropertiesReader(body); var propertiesReader = new MqttV500PropertiesReader(body);
while (propertiesReader.MoveNext()) while (propertiesReader.MoveNext())
{ {
if (packet.Properties == null)
{
packet.Properties = new MqttConnectPacketProperties();
}

if (propertiesReader.CurrentPropertyId == MqttPropertyId.SessionExpiryInterval) if (propertiesReader.CurrentPropertyId == MqttPropertyId.SessionExpiryInterval)
{ {
packet.Properties.SessionExpiryInterval = propertiesReader.ReadSessionExpiryInterval(); packet.Properties.SessionExpiryInterval = propertiesReader.ReadSessionExpiryInterval();
@@ -118,6 +123,11 @@ namespace MQTTnet.Formatter.V5
} }
else if (propertiesReader.CurrentPropertyId == MqttPropertyId.UserProperty) else if (propertiesReader.CurrentPropertyId == MqttPropertyId.UserProperty)
{ {
if (packet.Properties.UserProperties == null)
{
packet.Properties.UserProperties = new List<MqttUserProperty>();
}

propertiesReader.AddUserPropertyTo(packet.Properties.UserProperties); propertiesReader.AddUserPropertyTo(packet.Properties.UserProperties);
} }
else else
@@ -213,13 +223,17 @@ namespace MQTTnet.Formatter.V5
var packet = new MqttConnAckPacket var packet = new MqttConnAckPacket
{ {
IsSessionPresent = (acknowledgeFlags & 0x1) > 0, IsSessionPresent = (acknowledgeFlags & 0x1) > 0,
ReasonCode = (MqttConnectReasonCode)body.ReadByte(),
Properties = new MqttConnAckPacketProperties()
ReasonCode = (MqttConnectReasonCode)body.ReadByte()
}; };


var propertiesReader = new MqttV500PropertiesReader(body); var propertiesReader = new MqttV500PropertiesReader(body);
while (propertiesReader.MoveNext()) while (propertiesReader.MoveNext())
{ {
if (packet.Properties == null)
{
packet.Properties = new MqttConnAckPacketProperties();
}

if (propertiesReader.CurrentPropertyId == MqttPropertyId.SessionExpiryInterval) if (propertiesReader.CurrentPropertyId == MqttPropertyId.SessionExpiryInterval)
{ {
packet.Properties.SessionExpiryInterval = propertiesReader.ReadSessionExpiryInterval(); packet.Properties.SessionExpiryInterval = propertiesReader.ReadSessionExpiryInterval();
@@ -282,6 +296,11 @@ namespace MQTTnet.Formatter.V5
} }
else if (propertiesReader.CurrentPropertyId == MqttPropertyId.UserProperty) else if (propertiesReader.CurrentPropertyId == MqttPropertyId.UserProperty)
{ {
if (packet.Properties.UserProperties == null)
{
packet.Properties.UserProperties = new List<MqttUserProperty>();
}

propertiesReader.AddUserPropertyTo(packet.Properties.UserProperties); propertiesReader.AddUserPropertyTo(packet.Properties.UserProperties);
} }
else else
@@ -299,13 +318,17 @@ namespace MQTTnet.Formatter.V5


var packet = new MqttDisconnectPacket var packet = new MqttDisconnectPacket
{ {
ReasonCode = (MqttDisconnectReasonCode)body.ReadByte(),
Properties = new MqttDisconnectPacketProperties()
ReasonCode = (MqttDisconnectReasonCode)body.ReadByte()
}; };


var propertiesReader = new MqttV500PropertiesReader(body); var propertiesReader = new MqttV500PropertiesReader(body);
while (propertiesReader.MoveNext()) while (propertiesReader.MoveNext())
{ {
if (packet.Properties == null)
{
packet.Properties = new MqttDisconnectPacketProperties();
}

if (propertiesReader.CurrentPropertyId == MqttPropertyId.SessionExpiryInterval) if (propertiesReader.CurrentPropertyId == MqttPropertyId.SessionExpiryInterval)
{ {
packet.Properties.SessionExpiryInterval = propertiesReader.ReadSessionExpiryInterval(); packet.Properties.SessionExpiryInterval = propertiesReader.ReadSessionExpiryInterval();
@@ -320,6 +343,11 @@ namespace MQTTnet.Formatter.V5
} }
else if (propertiesReader.CurrentPropertyId == MqttPropertyId.UserProperty) else if (propertiesReader.CurrentPropertyId == MqttPropertyId.UserProperty)
{ {
if (packet.Properties.UserProperties == null)
{
packet.Properties.UserProperties = new List<MqttUserProperty>();
}

propertiesReader.AddUserPropertyTo(packet.Properties.UserProperties); propertiesReader.AddUserPropertyTo(packet.Properties.UserProperties);
} }
else else
@@ -337,19 +365,28 @@ namespace MQTTnet.Formatter.V5


var packet = new MqttSubscribePacket var packet = new MqttSubscribePacket
{ {
PacketIdentifier = body.ReadTwoByteInteger(),
Properties = new MqttSubscribePacketProperties()
PacketIdentifier = body.ReadTwoByteInteger()
}; };


var propertiesReader = new MqttV500PropertiesReader(body); var propertiesReader = new MqttV500PropertiesReader(body);
while (propertiesReader.MoveNext()) while (propertiesReader.MoveNext())
{ {
if (packet.Properties == null)
{
packet.Properties = new MqttSubscribePacketProperties();
}

if (propertiesReader.CurrentPropertyId == MqttPropertyId.SubscriptionIdentifier) if (propertiesReader.CurrentPropertyId == MqttPropertyId.SubscriptionIdentifier)
{ {
packet.Properties.SubscriptionIdentifier = propertiesReader.ReadSubscriptionIdentifier(); packet.Properties.SubscriptionIdentifier = propertiesReader.ReadSubscriptionIdentifier();
} }
else if (propertiesReader.CurrentPropertyId == MqttPropertyId.UserProperty) else if (propertiesReader.CurrentPropertyId == MqttPropertyId.UserProperty)
{ {
if (packet.Properties.UserProperties == null)
{
packet.Properties.UserProperties = new List<MqttUserProperty>();
}

propertiesReader.AddUserPropertyTo(packet.Properties.UserProperties); propertiesReader.AddUserPropertyTo(packet.Properties.UserProperties);
} }
else else
@@ -387,19 +424,28 @@ namespace MQTTnet.Formatter.V5


var packet = new MqttSubAckPacket var packet = new MqttSubAckPacket
{ {
PacketIdentifier = body.ReadTwoByteInteger(),
Properties = new MqttSubAckPacketProperties()
PacketIdentifier = body.ReadTwoByteInteger()
}; };


var propertiesReader = new MqttV500PropertiesReader(body); var propertiesReader = new MqttV500PropertiesReader(body);
while (propertiesReader.MoveNext()) while (propertiesReader.MoveNext())
{ {
if (packet.Properties == null)
{
packet.Properties = new MqttSubAckPacketProperties();
}

if (propertiesReader.CurrentPropertyId == MqttPropertyId.ReasonString) if (propertiesReader.CurrentPropertyId == MqttPropertyId.ReasonString)
{ {
packet.Properties.ReasonString = propertiesReader.ReadReasonString(); packet.Properties.ReasonString = propertiesReader.ReadReasonString();
} }
else if (propertiesReader.CurrentPropertyId == MqttPropertyId.UserProperty) else if (propertiesReader.CurrentPropertyId == MqttPropertyId.UserProperty)
{ {
if (packet.Properties.UserProperties == null)
{
packet.Properties.UserProperties = new List<MqttUserProperty>();
}

propertiesReader.AddUserPropertyTo(packet.Properties.UserProperties); propertiesReader.AddUserPropertyTo(packet.Properties.UserProperties);
} }
else else
@@ -423,15 +469,24 @@ namespace MQTTnet.Formatter.V5


var packet = new MqttUnsubscribePacket var packet = new MqttUnsubscribePacket
{ {
PacketIdentifier = body.ReadTwoByteInteger(),
Properties = new MqttUnsubscribePacketProperties()
PacketIdentifier = body.ReadTwoByteInteger()
}; };


var propertiesReader = new MqttV500PropertiesReader(body); var propertiesReader = new MqttV500PropertiesReader(body);
while (propertiesReader.MoveNext()) while (propertiesReader.MoveNext())
{ {
if (packet.Properties == null)
{
packet.Properties = new MqttUnsubscribePacketProperties();
}

if (propertiesReader.CurrentPropertyId == MqttPropertyId.UserProperty) if (propertiesReader.CurrentPropertyId == MqttPropertyId.UserProperty)
{ {
if (packet.Properties.UserProperties == null)
{
packet.Properties.UserProperties = new List<MqttUserProperty>();
}

propertiesReader.AddUserPropertyTo(packet.Properties.UserProperties); propertiesReader.AddUserPropertyTo(packet.Properties.UserProperties);
} }
else else
@@ -454,19 +509,28 @@ namespace MQTTnet.Formatter.V5


var packet = new MqttUnsubAckPacket var packet = new MqttUnsubAckPacket
{ {
PacketIdentifier = body.ReadTwoByteInteger(),
Properties = new MqttUnsubAckPacketProperties()
PacketIdentifier = body.ReadTwoByteInteger()
}; };


var propertiesReader = new MqttV500PropertiesReader(body); var propertiesReader = new MqttV500PropertiesReader(body);
while (propertiesReader.MoveNext()) while (propertiesReader.MoveNext())
{ {
if (packet.Properties == null)
{
packet.Properties = new MqttUnsubAckPacketProperties();
}

if (propertiesReader.CurrentPropertyId == MqttPropertyId.ReasonString) if (propertiesReader.CurrentPropertyId == MqttPropertyId.ReasonString)
{ {
packet.Properties.ReasonString = propertiesReader.ReadReasonString(); packet.Properties.ReasonString = propertiesReader.ReadReasonString();
} }
else if (propertiesReader.CurrentPropertyId == MqttPropertyId.UserProperty) else if (propertiesReader.CurrentPropertyId == MqttPropertyId.UserProperty)
{ {
if (packet.Properties.UserProperties == null)
{
packet.Properties.UserProperties = new List<MqttUserProperty>();
}

propertiesReader.AddUserPropertyTo(packet.Properties.UserProperties); propertiesReader.AddUserPropertyTo(packet.Properties.UserProperties);
} }
else else
@@ -486,12 +550,12 @@ namespace MQTTnet.Formatter.V5


private static MqttBasePacket DecodePingReqPacket() private static MqttBasePacket DecodePingReqPacket()
{ {
return new MqttPingReqPacket();
return PingReqPacket;
} }


private static MqttBasePacket DecodePingRespPacket() private static MqttBasePacket DecodePingRespPacket()
{ {
return new MqttPingRespPacket();
return PingRespPacket;
} }


private static MqttBasePacket DecodePublishPacket(byte header, IMqttPacketBodyReader body) private static MqttBasePacket DecodePublishPacket(byte header, IMqttPacketBodyReader body)
@@ -507,8 +571,7 @@ namespace MQTTnet.Formatter.V5
Topic = body.ReadStringWithLengthPrefix(), Topic = body.ReadStringWithLengthPrefix(),
Retain = retain, Retain = retain,
QualityOfServiceLevel = qos, QualityOfServiceLevel = qos,
Dup = dup,
Properties = new MqttPublishPacketProperties()
Dup = dup
}; };


if (qos > 0) if (qos > 0)
@@ -519,6 +582,11 @@ namespace MQTTnet.Formatter.V5
var propertiesReader = new MqttV500PropertiesReader(body); var propertiesReader = new MqttV500PropertiesReader(body);
while (propertiesReader.MoveNext()) while (propertiesReader.MoveNext())
{ {
if (packet.Properties == null)
{
packet.Properties = new MqttPublishPacketProperties();
}

if (propertiesReader.CurrentPropertyId == MqttPropertyId.PayloadFormatIndicator) if (propertiesReader.CurrentPropertyId == MqttPropertyId.PayloadFormatIndicator)
{ {
packet.Properties.PayloadFormatIndicator = propertiesReader.ReadPayloadFormatIndicator(); packet.Properties.PayloadFormatIndicator = propertiesReader.ReadPayloadFormatIndicator();
@@ -569,7 +637,7 @@ namespace MQTTnet.Formatter.V5


if (!body.EndOfStream) if (!body.EndOfStream)
{ {
packet.Payload = body.ReadRemainingData().ToArray();
packet.Payload = body.ReadRemainingData();
} }


return packet; return packet;
@@ -581,8 +649,7 @@ namespace MQTTnet.Formatter.V5


var packet = new MqttPubAckPacket var packet = new MqttPubAckPacket
{ {
PacketIdentifier = body.ReadTwoByteInteger(),
Properties = new MqttPubAckPacketProperties()
PacketIdentifier = body.ReadTwoByteInteger()
}; };


if (body.EndOfStream) if (body.EndOfStream)
@@ -596,12 +663,22 @@ namespace MQTTnet.Formatter.V5
var propertiesReader = new MqttV500PropertiesReader(body); var propertiesReader = new MqttV500PropertiesReader(body);
while (propertiesReader.MoveNext()) while (propertiesReader.MoveNext())
{ {
if (packet.Properties == null)
{
packet.Properties = new MqttPubAckPacketProperties();
}

if (propertiesReader.CurrentPropertyId == MqttPropertyId.ReasonString) if (propertiesReader.CurrentPropertyId == MqttPropertyId.ReasonString)
{ {
packet.Properties.ReasonString = propertiesReader.ReadReasonString(); packet.Properties.ReasonString = propertiesReader.ReadReasonString();
} }
else if (propertiesReader.CurrentPropertyId == MqttPropertyId.UserProperty) else if (propertiesReader.CurrentPropertyId == MqttPropertyId.UserProperty)
{ {
if (packet.Properties.UserProperties == null)
{
packet.Properties.UserProperties = new List<MqttUserProperty>();
}

propertiesReader.AddUserPropertyTo(packet.Properties.UserProperties); propertiesReader.AddUserPropertyTo(packet.Properties.UserProperties);
} }
else else
@@ -619,8 +696,7 @@ namespace MQTTnet.Formatter.V5


var packet = new MqttPubRecPacket var packet = new MqttPubRecPacket
{ {
PacketIdentifier = body.ReadTwoByteInteger(),
Properties = new MqttPubRecPacketProperties()
PacketIdentifier = body.ReadTwoByteInteger()
}; };


if (body.EndOfStream) if (body.EndOfStream)
@@ -634,12 +710,22 @@ namespace MQTTnet.Formatter.V5
var propertiesReader = new MqttV500PropertiesReader(body); var propertiesReader = new MqttV500PropertiesReader(body);
while (propertiesReader.MoveNext()) while (propertiesReader.MoveNext())
{ {
if (packet.Properties == null)
{
packet.Properties = new MqttPubRecPacketProperties();
}

if (propertiesReader.CurrentPropertyId == MqttPropertyId.ReasonString) if (propertiesReader.CurrentPropertyId == MqttPropertyId.ReasonString)
{ {
packet.Properties.ReasonString = propertiesReader.ReadReasonString(); packet.Properties.ReasonString = propertiesReader.ReadReasonString();
} }
else if (propertiesReader.CurrentPropertyId == MqttPropertyId.UserProperty) else if (propertiesReader.CurrentPropertyId == MqttPropertyId.UserProperty)
{ {
if (packet.Properties.UserProperties == null)
{
packet.Properties.UserProperties = new List<MqttUserProperty>();
}

propertiesReader.AddUserPropertyTo(packet.Properties.UserProperties); propertiesReader.AddUserPropertyTo(packet.Properties.UserProperties);
} }
else else
@@ -657,8 +743,7 @@ namespace MQTTnet.Formatter.V5


var packet = new MqttPubRelPacket var packet = new MqttPubRelPacket
{ {
PacketIdentifier = body.ReadTwoByteInteger(),
Properties = new MqttPubRelPacketProperties()
PacketIdentifier = body.ReadTwoByteInteger()
}; };


if (body.EndOfStream) if (body.EndOfStream)
@@ -672,12 +757,22 @@ namespace MQTTnet.Formatter.V5
var propertiesReader = new MqttV500PropertiesReader(body); var propertiesReader = new MqttV500PropertiesReader(body);
while (propertiesReader.MoveNext()) while (propertiesReader.MoveNext())
{ {
if (packet.Properties == null)
{
packet.Properties = new MqttPubRelPacketProperties();
}

if (propertiesReader.CurrentPropertyId == MqttPropertyId.ReasonString) if (propertiesReader.CurrentPropertyId == MqttPropertyId.ReasonString)
{ {
packet.Properties.ReasonString = propertiesReader.ReadReasonString(); packet.Properties.ReasonString = propertiesReader.ReadReasonString();
} }
else if (propertiesReader.CurrentPropertyId == MqttPropertyId.UserProperty) else if (propertiesReader.CurrentPropertyId == MqttPropertyId.UserProperty)
{ {
if (packet.Properties.UserProperties == null)
{
packet.Properties.UserProperties = new List<MqttUserProperty>();
}

propertiesReader.AddUserPropertyTo(packet.Properties.UserProperties); propertiesReader.AddUserPropertyTo(packet.Properties.UserProperties);
} }
else else
@@ -695,8 +790,7 @@ namespace MQTTnet.Formatter.V5


var packet = new MqttPubCompPacket var packet = new MqttPubCompPacket
{ {
PacketIdentifier = body.ReadTwoByteInteger(),
Properties = new MqttPubCompPacketProperties()
PacketIdentifier = body.ReadTwoByteInteger()
}; };


if (body.EndOfStream) if (body.EndOfStream)
@@ -710,12 +804,22 @@ namespace MQTTnet.Formatter.V5
var propertiesReader = new MqttV500PropertiesReader(body); var propertiesReader = new MqttV500PropertiesReader(body);
while (propertiesReader.MoveNext()) while (propertiesReader.MoveNext())
{ {
if (packet.Properties == null)
{
packet.Properties = new MqttPubCompPacketProperties();
}

if (propertiesReader.CurrentPropertyId == MqttPropertyId.ReasonString) if (propertiesReader.CurrentPropertyId == MqttPropertyId.ReasonString)
{ {
packet.Properties.ReasonString = propertiesReader.ReadReasonString(); packet.Properties.ReasonString = propertiesReader.ReadReasonString();
} }
else if (propertiesReader.CurrentPropertyId == MqttPropertyId.UserProperty) else if (propertiesReader.CurrentPropertyId == MqttPropertyId.UserProperty)
{ {
if (packet.Properties.UserProperties == null)
{
packet.Properties.UserProperties = new List<MqttUserProperty>();
}

propertiesReader.AddUserPropertyTo(packet.Properties.UserProperties); propertiesReader.AddUserPropertyTo(packet.Properties.UserProperties);
} }
else else
@@ -731,10 +835,7 @@ namespace MQTTnet.Formatter.V5
{ {
ThrowIfBodyIsEmpty(body); ThrowIfBodyIsEmpty(body);


var packet = new MqttAuthPacket
{
Properties = new MqttAuthPacketProperties()
};
var packet = new MqttAuthPacket();


if (body.EndOfStream) if (body.EndOfStream)
{ {
@@ -747,6 +848,11 @@ namespace MQTTnet.Formatter.V5
var propertiesReader = new MqttV500PropertiesReader(body); var propertiesReader = new MqttV500PropertiesReader(body);
while (propertiesReader.MoveNext()) while (propertiesReader.MoveNext())
{ {
if (packet.Properties == null)
{
packet.Properties = new MqttAuthPacketProperties();
}

if (propertiesReader.CurrentPropertyId == MqttPropertyId.AuthenticationMethod) if (propertiesReader.CurrentPropertyId == MqttPropertyId.AuthenticationMethod)
{ {
packet.Properties.AuthenticationMethod = propertiesReader.ReadAuthenticationMethod(); packet.Properties.AuthenticationMethod = propertiesReader.ReadAuthenticationMethod();
@@ -761,6 +867,11 @@ namespace MQTTnet.Formatter.V5
} }
else if (propertiesReader.CurrentPropertyId == MqttPropertyId.UserProperty) else if (propertiesReader.CurrentPropertyId == MqttPropertyId.UserProperty)
{ {
if (packet.Properties.UserProperties == null)
{
packet.Properties.UserProperties = new List<MqttUserProperty>();
}

propertiesReader.AddUserPropertyTo(packet.Properties.UserProperties); propertiesReader.AddUserPropertyTo(packet.Properties.UserProperties);
} }
else else


+ 1
- 1
Source/MQTTnet/Packets/MqttAuthPacketProperties.cs View File

@@ -10,6 +10,6 @@ namespace MQTTnet.Packets


public string ReasonString { get; set; } public string ReasonString { get; set; }


public List<MqttUserProperty> UserProperties { get; } = new List<MqttUserProperty>();
public List<MqttUserProperty> UserProperties { get; set; }
} }
} }

+ 1
- 1
Source/MQTTnet/Packets/MqttConnAckPacketProperties.cs View File

@@ -18,7 +18,7 @@ namespace MQTTnet.Packets


public string ReasonString { get; set; } public string ReasonString { get; set; }


public List<MqttUserProperty> UserProperties { get; } = new List<MqttUserProperty>();
public List<MqttUserProperty> UserProperties { get; set; }


public bool? WildcardSubscriptionAvailable { get; set; } public bool? WildcardSubscriptionAvailable { get; set; }




+ 1
- 1
Source/MQTTnet/Packets/MqttConnectPacketProperties.cs View File

@@ -22,6 +22,6 @@ namespace MQTTnet.Packets


public uint? MaximumPacketSize { get; set; } public uint? MaximumPacketSize { get; set; }


public List<MqttUserProperty> UserProperties { get; } = new List<MqttUserProperty>();
public List<MqttUserProperty> UserProperties { get; set; }
} }
} }

+ 1
- 1
Source/MQTTnet/Packets/MqttDisconnectPacketProperties.cs View File

@@ -8,7 +8,7 @@ namespace MQTTnet.Packets


public string ReasonString { get; set; } public string ReasonString { get; set; }


public List<MqttUserProperty> UserProperties { get; } = new List<MqttUserProperty>();
public List<MqttUserProperty> UserProperties { get; set; }


public string ServerReference { get; set; } public string ServerReference { get; set; }
} }

+ 1
- 1
Source/MQTTnet/Packets/MqttPubAckPacketProperties.cs View File

@@ -6,6 +6,6 @@ namespace MQTTnet.Packets
{ {
public string ReasonString { get; set; } public string ReasonString { get; set; }


public List<MqttUserProperty> UserProperties { get; } = new List<MqttUserProperty>();
public List<MqttUserProperty> UserProperties { get; set; }
} }
} }

+ 1
- 1
Source/MQTTnet/Packets/MqttPubCompPacketProperties.cs View File

@@ -6,6 +6,6 @@ namespace MQTTnet.Packets
{ {
public string ReasonString { get; set; } public string ReasonString { get; set; }


public List<MqttUserProperty> UserProperties { get; } = new List<MqttUserProperty>();
public List<MqttUserProperty> UserProperties { get; set; }
} }
} }

+ 1
- 1
Source/MQTTnet/Packets/MqttPubRecPacketProperties.cs View File

@@ -6,6 +6,6 @@ namespace MQTTnet.Packets
{ {
public string ReasonString { get; set; } public string ReasonString { get; set; }


public List<MqttUserProperty> UserProperties { get; } = new List<MqttUserProperty>();
public List<MqttUserProperty> UserProperties { get; set; }
} }
} }

+ 1
- 1
Source/MQTTnet/Packets/MqttPubRelPacketProperties.cs View File

@@ -6,6 +6,6 @@ namespace MQTTnet.Packets
{ {
public string ReasonString { get; set; } public string ReasonString { get; set; }


public List<MqttUserProperty> UserProperties { get; } = new List<MqttUserProperty>();
public List<MqttUserProperty> UserProperties { get; set; }
} }
} }

+ 1
- 1
Source/MQTTnet/Packets/MqttSubAckPacket.cs View File

@@ -8,7 +8,7 @@ namespace MQTTnet.Packets
{ {
public ushort? PacketIdentifier { get; set; } public ushort? PacketIdentifier { get; set; }


public List<MqttSubscribeReturnCode> ReturnCodes { get; } = new List<MqttSubscribeReturnCode>();
public List<MqttSubscribeReturnCode> ReturnCodes { get; set; } = new List<MqttSubscribeReturnCode>();


#region Added in MQTTv5.0.0 #region Added in MQTTv5.0.0




+ 1
- 1
Source/MQTTnet/Packets/MqttSubAckPacketProperties.cs View File

@@ -6,6 +6,6 @@ namespace MQTTnet.Packets
{ {
public string ReasonString { get; set; } public string ReasonString { get; set; }


public List<MqttUserProperty> UserProperties { get; } = new List<MqttUserProperty>();
public List<MqttUserProperty> UserProperties { get; set; }
} }
} }

+ 1
- 1
Source/MQTTnet/Packets/MqttSubscribePacket.cs View File

@@ -7,7 +7,7 @@ namespace MQTTnet.Packets
{ {
public ushort? PacketIdentifier { get; set; } public ushort? PacketIdentifier { get; set; }


public List<TopicFilter> TopicFilters { get; } = new List<TopicFilter>();
public List<TopicFilter> TopicFilters { get; set; } = new List<TopicFilter>();


#region Added in MQTTv5 #region Added in MQTTv5




+ 1
- 1
Source/MQTTnet/Packets/MqttSubscribePacketProperties.cs View File

@@ -6,6 +6,6 @@ namespace MQTTnet.Packets
{ {
public uint? SubscriptionIdentifier { get; set; } public uint? SubscriptionIdentifier { get; set; }


public List<MqttUserProperty> UserProperties { get; } = new List<MqttUserProperty>();
public List<MqttUserProperty> UserProperties { get; set; }
} }
} }

+ 1
- 1
Source/MQTTnet/Packets/MqttUnsubAckPacket.cs View File

@@ -12,7 +12,7 @@ namespace MQTTnet.Packets


public MqttUnsubAckPacketProperties Properties { get; set; } public MqttUnsubAckPacketProperties Properties { get; set; }


public List<MqttUnsubscribeReasonCode> ReasonCodes { get; } = new List<MqttUnsubscribeReasonCode>();
public List<MqttUnsubscribeReasonCode> ReasonCodes { get; set; } = new List<MqttUnsubscribeReasonCode>();


#endregion #endregion




+ 1
- 1
Source/MQTTnet/Packets/MqttUnsubAckPacketProperties.cs View File

@@ -6,6 +6,6 @@ namespace MQTTnet.Packets
{ {
public string ReasonString { get; set; } public string ReasonString { get; set; }


public List<MqttUserProperty> UserProperties { get; } = new List<MqttUserProperty>();
public List<MqttUserProperty> UserProperties { get; set; }
} }
} }

+ 1
- 1
Source/MQTTnet/Packets/MqttUnsubscribePacket.cs View File

@@ -6,7 +6,7 @@ namespace MQTTnet.Packets
{ {
public ushort? PacketIdentifier { get; set; } public ushort? PacketIdentifier { get; set; }


public List<string> TopicFilters { get; } = new List<string>();
public List<string> TopicFilters { get; set; } = new List<string>();


#region Added in MQTTv5 #region Added in MQTTv5




+ 1
- 1
Source/MQTTnet/Packets/MqttUnsubscribePacketProperties.cs View File

@@ -4,6 +4,6 @@ namespace MQTTnet.Packets
{ {
public class MqttUnsubscribePacketProperties public class MqttUnsubscribePacketProperties
{ {
public List<MqttUserProperty> UserProperties { get; } = new List<MqttUserProperty>();
public List<MqttUserProperty> UserProperties { get; set; }
} }
} }

Loading…
Cancel
Save