Sfoglia il codice sorgente

Add more pacakges.

release/3.x.x
Christian Kratky 6 anni fa
parent
commit
0f5fb8aa3a
27 ha cambiato i file con 206 aggiunte e 33 eliminazioni
  1. BIN
     
  2. +3
    -2
      README.md
  3. +1
    -1
      Source/MQTTnet/Formatter/V500/MqttV500PacketDecoder.cs
  4. +5
    -5
      Source/MQTTnet/Formatter/V500/MqttV500PacketEncoder.cs
  5. +2
    -1
      Source/MQTTnet/Formatter/V500/MqttV500PacketFormatter.cs
  6. +2
    -2
      Source/MQTTnet/Packets/MqttConnAckPacket.cs
  7. +1
    -1
      Source/MQTTnet/Packets/MqttConnectPacket.cs
  8. +2
    -2
      Source/MQTTnet/Packets/MqttPubAckPacket.cs
  9. +12
    -2
      Source/MQTTnet/Packets/MqttPubCompPacket.cs
  10. +11
    -0
      Source/MQTTnet/Packets/MqttPubCompPacketProperties.cs
  11. +12
    -2
      Source/MQTTnet/Packets/MqttPubRecPacket.cs
  12. +11
    -0
      Source/MQTTnet/Packets/MqttPubRecPacketProperties.cs
  13. +12
    -2
      Source/MQTTnet/Packets/MqttPubRelPacket.cs
  14. +11
    -0
      Source/MQTTnet/Packets/MqttPubRelPacketProperties.cs
  15. +3
    -8
      Source/MQTTnet/Packets/MqttPublishPacket.cs
  16. +10
    -2
      Source/MQTTnet/Packets/MqttSubAckPacket.cs
  17. +11
    -0
      Source/MQTTnet/Packets/MqttSubAckPacketProperties.cs
  18. +7
    -1
      Source/MQTTnet/Packets/MqttSubscribePacket.cs
  19. +11
    -0
      Source/MQTTnet/Packets/MqttSubscribePacketProperties.cs
  20. +1
    -1
      Source/MQTTnet/Packets/MqttUnsubAckPacket.cs
  21. +1
    -1
      Source/MQTTnet/Packets/MqttUnsubscribe.cs
  22. +8
    -0
      Source/MQTTnet/Protocol/MqttPubCompReasonCode.cs
  23. +15
    -0
      Source/MQTTnet/Protocol/MqttPubRecReasonCode.cs
  24. +8
    -0
      Source/MQTTnet/Protocol/MqttPubRelReasonCode.cs
  25. +9
    -0
      Source/MQTTnet/Protocol/MqttRetainHandling.cs
  26. +18
    -0
      Source/MQTTnet/Protocol/MqttSubscribeReasonCode.cs
  27. +19
    -0
      Source/MQTTnet/TopicFilter.cs

BIN
Vedi File


+ 3
- 2
README.md Vedi File

@@ -20,7 +20,7 @@ MQTTnet is a high performance .NET library for MQTT based communication. It prov

* Async support
* TLS 1.2 support for client and server (but not UWP servers)
* Extensible communication channels (i.e. In-Memory, TCP, TCP+TLS, WS)
* Extensible communication channels (e.g. In-Memory, TCP, TCP+TLS, WS)
* Lightweight (only the low level implementation of MQTT, no overhead)
* Performance optimized (processing ~70.000 messages / second)*
* Interfaces included for mocking and testing
@@ -48,6 +48,7 @@ MQTTnet is a high performance .NET library for MQTT based communication. It prov
* WebSockets supported (via ASP.NET Core 2.0, separate nuget)
* A custom message interceptor can be added which allows transforming or extending every received application message
* Validate subscriptions and deny subscribing of certain topics depending on requesting clients
* Connect clients with different protocol versions at the same time.

## Supported frameworks

@@ -62,7 +63,7 @@ MQTTnet is a high performance .NET library for MQTT based communication. It prov

## Supported MQTT versions

* 5.0.0 (planned)
* 5.0.0
* 3.1.1
* 3.1.0



+ 1
- 1
Source/MQTTnet/Formatter/V500/MqttV500PacketDecoder.cs Vedi File

@@ -21,7 +21,7 @@ namespace MQTTnet.Formatter.V500

packet.IsSessionPresent = (acknowledgeFlags & 0x1) > 0;
packet.ConnectReturnCode = (MqttConnectReturnCode)body.ReadByte();
packet.ConnectReasonCode = (MqttConnectReasonCode)body.ReadByte();
packet.ReasonCode = (MqttConnectReasonCode)body.ReadByte();

var propertiesLength = body.ReadVariableLengthInteger();
if (propertiesLength > 0)


+ 5
- 5
Source/MQTTnet/Formatter/V500/MqttV500PacketEncoder.cs Vedi File

@@ -97,9 +97,9 @@ namespace MQTTnet.Formatter.V500
if (packet == null) throw new ArgumentNullException(nameof(packet));
if (packetWriter == null) throw new ArgumentNullException(nameof(packetWriter));

if (!packet.ConnectReasonCode.HasValue)
if (!packet.ReasonCode.HasValue)
{
throw new MqttProtocolViolationException("The ConnectReasonCode must be set for MQTT version 5.");
throw new MqttProtocolViolationException("The ReasonCode must be set for MQTT version 5.");
}

byte connectAcknowledgeFlags = 0x0;
@@ -110,7 +110,7 @@ namespace MQTTnet.Formatter.V500

packetWriter.Write(connectAcknowledgeFlags);
packetWriter.Write((byte)packet.ConnectReturnCode);
packetWriter.Write((byte)packet.ConnectReasonCode.Value);
packetWriter.Write((byte)packet.ReasonCode.Value);

var propertiesWriter = new MqttV500PropertiesWriter();
if (packet.Properties != null)
@@ -209,13 +209,13 @@ namespace MQTTnet.Formatter.V500
throw new MqttProtocolViolationException("PubAck packet has no packet identifier.");
}

if (!packet.ConnectReasonCode.HasValue)
if (!packet.ReasonCode.HasValue)
{
throw new MqttProtocolViolationException("PubAck packet must contain a connect reason.");
}

packetWriter.Write(packet.PacketIdentifier.Value);
packetWriter.Write((byte)packet.ConnectReasonCode.Value);
packetWriter.Write((byte)packet.ReasonCode.Value);

return MqttPacketWriter.BuildFixedHeader(MqttControlPacketType.PubAck);
}


+ 2
- 1
Source/MQTTnet/Formatter/V500/MqttV500PacketFormatter.cs Vedi File

@@ -1,4 +1,5 @@
using System;
using System.Collections.Generic;
using MQTTnet.Formatter.V311;
using MQTTnet.Packets;

@@ -22,7 +23,7 @@ namespace MQTTnet.Formatter.V500
Dup = false,
Properties = new MqttPublishPacketProperties
{
UserProperties = applicationMessage.UserProperties
UserProperties = new List<MqttUserProperty>(applicationMessage.UserProperties)
}
};
}


+ 2
- 2
Source/MQTTnet/Packets/MqttConnAckPacket.cs Vedi File

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

#region Added in MQTTv5

public MqttConnectReasonCode? ConnectReasonCode { get; set; }
public MqttConnectReasonCode? ReasonCode { get; set; }

public MqttConnAckPacketProperties Properties { get; set; }

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

public override string ToString()
{
return "ConnAck: [ConnectReturnCode=" + ConnectReturnCode + "] [IsSessionPresent=" + IsSessionPresent + "]";
return string.Concat("ConnAck: [ConnectReturnCode=", ConnectReturnCode, "] [ReasonCode=", ReasonCode, "] [IsSessionPresent=", IsSessionPresent, "]");
}
}
}

+ 1
- 1
Source/MQTTnet/Packets/MqttConnectPacket.cs Vedi File

@@ -29,7 +29,7 @@

public override string ToString()
{
return "Connect: [ProtocolLevel=" + ProtocolLevel + "] [ClientId=" + ClientId + "] [Username=" + Username + "] [Password=" + Password + "] [KeepAlivePeriod=" + KeepAlivePeriod + "] [CleanSession=" + CleanSession + "]";
return string.Concat("Connect: [ProtocolLevel=", ProtocolLevel, "] [ClientId=", ClientId, "] [Username=", Username, "] [Password=", Password, "] [KeepAlivePeriod=", KeepAlivePeriod, "] [CleanSession=", CleanSession, "]");
}
}
}

+ 2
- 2
Source/MQTTnet/Packets/MqttPubAckPacket.cs Vedi File

@@ -6,7 +6,7 @@ namespace MQTTnet.Packets
{
#region Added in MQTTv5

public MqttPubAckReasonCode? ConnectReasonCode { get; set; }
public MqttPubAckReasonCode? ReasonCode { get; set; }

public MqttPubAckPacketProperties Properties { get; set; }

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

public override string ToString()
{
return $"PubAck: [PacketIdentifier={PacketIdentifier}] [ConnectReasonCode={ConnectReasonCode}]";
return string.Concat("PubAck: [PacketIdentifier=", PacketIdentifier, "] [ConnectReasonCode=", ReasonCode, "]");
}
}
}

+ 12
- 2
Source/MQTTnet/Packets/MqttPubCompPacket.cs Vedi File

@@ -1,10 +1,20 @@
namespace MQTTnet.Packets
using MQTTnet.Protocol;

namespace MQTTnet.Packets
{
public class MqttPubCompPacket : MqttBasePublishPacket
{
#region Added in MQTTv5

public MqttPubCompReasonCode? ReasonCode { get; set; }

public MqttPubCompPacketProperties Properties { get; set; }

#endregion

public override string ToString()
{
return "PubComp";
return string.Concat("PubComp: [PacketIdentifier=", PacketIdentifier, "] [ReasonCode=", ReasonCode, "]");
}
}
}

+ 11
- 0
Source/MQTTnet/Packets/MqttPubCompPacketProperties.cs Vedi File

@@ -0,0 +1,11 @@
using System.Collections.Generic;

namespace MQTTnet.Packets
{
public class MqttPubCompPacketProperties
{
public string ReasonString { get; set; }

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

+ 12
- 2
Source/MQTTnet/Packets/MqttPubRecPacket.cs Vedi File

@@ -1,10 +1,20 @@
namespace MQTTnet.Packets
using MQTTnet.Protocol;

namespace MQTTnet.Packets
{
public class MqttPubRecPacket : MqttBasePublishPacket
{
#region Added in MQTTv5

public MqttPubRecReasonCode? ReasonCode { get; set; }

public MqttPubRecPacketProperties Properties { get; set; }

#endregion

public override string ToString()
{
return "PubRec";
return string.Concat("PubRec: [PacketIdentifier=", PacketIdentifier, "] [ReasonCode=", ReasonCode, "]");
}
}
}

+ 11
- 0
Source/MQTTnet/Packets/MqttPubRecPacketProperties.cs Vedi File

@@ -0,0 +1,11 @@
using System.Collections.Generic;

namespace MQTTnet.Packets
{
public class MqttPubRecPacketProperties
{
public string ReasonString { get; set; }

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

+ 12
- 2
Source/MQTTnet/Packets/MqttPubRelPacket.cs Vedi File

@@ -1,10 +1,20 @@
namespace MQTTnet.Packets
using MQTTnet.Protocol;

namespace MQTTnet.Packets
{
public class MqttPubRelPacket : MqttBasePublishPacket
{
#region Added in MQTTv5

public MqttPubRelReasonCode? ReasonCode { get; set; }

public MqttPubRelPacketProperties Properties { get; set; }

#endregion

public override string ToString()
{
return "PubRel";
return string.Concat("PubRel: [PacketIdentifier=", PacketIdentifier, "] [ReasonCode=", ReasonCode, "]");
}
}
}

+ 11
- 0
Source/MQTTnet/Packets/MqttPubRelPacketProperties.cs Vedi File

@@ -0,0 +1,11 @@
using System.Collections.Generic;

namespace MQTTnet.Packets
{
public class MqttPubRelPacketProperties
{
public string ReasonString { get; set; }

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

+ 3
- 8
Source/MQTTnet/Packets/MqttPublishPacket.cs Vedi File

@@ -15,19 +15,14 @@ namespace MQTTnet.Packets
public byte[] Payload { get; set; }

#region Added in MQTTv5
public MqttPublishPacketProperties Properties { get; set; }
#endregion

public override string ToString()
{
return "Publish: [Topic=" + Topic + "]" +
" [Payload.Length=" + Payload?.Length + "]" +
" [QoSLevel=" + QualityOfServiceLevel + "]" +
" [Dup=" + Dup + "]" +
" [Retain=" + Retain + "]" +
" [PacketIdentifier=" + PacketIdentifier + "]";
return string.Concat("Publish: [Topic=", Topic, "] [Payload.Length=", Payload?.Length, "] [QoSLevel=", QualityOfServiceLevel, "] [Dup=", Dup, "] [Retain=", Retain, "] [PacketIdentifier=", PacketIdentifier, "]");
}
}
}

+ 10
- 2
Source/MQTTnet/Packets/MqttSubAckPacket.cs Vedi File

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

public IList<MqttSubscribeReturnCode> SubscribeReturnCodes { get; } = new List<MqttSubscribeReturnCode>();
public List<MqttSubscribeReturnCode> SubscribeReturnCodes { get; } = new List<MqttSubscribeReturnCode>();

#region Added in MQTTv5

public List<MqttSubscribeReasonCode?> ReasonCodes { get; set; }

public MqttSubAckPacketProperties Properties { get; set; }

#endregion

public override string ToString()
{
var subscribeReturnCodesText = string.Join(",", SubscribeReturnCodes.Select(f => f.ToString()));
return "SubAck: [PacketIdentifier=" + PacketIdentifier + "] [SubscribeReturnCodes=" + subscribeReturnCodesText + "]";
return string.Concat("SubAck: [PacketIdentifier=", PacketIdentifier, "] [SubscribeReturnCodes=", subscribeReturnCodesText, "]");
}
}
}

+ 11
- 0
Source/MQTTnet/Packets/MqttSubAckPacketProperties.cs Vedi File

@@ -0,0 +1,11 @@
using System.Collections.Generic;

namespace MQTTnet.Packets
{
public class MqttSubAckPacketProperties
{
public string ReasonString { get; set; }

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

+ 7
- 1
Source/MQTTnet/Packets/MqttSubscribePacket.cs Vedi File

@@ -9,10 +9,16 @@ namespace MQTTnet.Packets

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

#region Added in MQTTv5

public MqttSubscribePacketProperties Properties { get; set; }

#endregion

public override string ToString()
{
var topicFiltersText = string.Join(",", TopicFilters.Select(f => f.Topic + "@" + f.QualityOfServiceLevel));
return "Subscribe: [PacketIdentifier=" + PacketIdentifier + "] [TopicFilters=" + topicFiltersText + "]";
return string.Concat("Subscribe: [PacketIdentifier=", PacketIdentifier, "] [TopicFilters=", topicFiltersText, "]");
}
}
}

+ 11
- 0
Source/MQTTnet/Packets/MqttSubscribePacketProperties.cs Vedi File

@@ -0,0 +1,11 @@
using System.Collections.Generic;

namespace MQTTnet.Packets
{
public class MqttSubscribePacketProperties
{
public uint? SubscriptionIdentifier { get; set; }

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

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

@@ -6,7 +6,7 @@

public override string ToString()
{
return "UnsubAck: [PacketIdentifier=" + PacketIdentifier + "]";
return string.Concat("UnsubAck: [PacketIdentifier=", PacketIdentifier, "]");
}
}
}

+ 1
- 1
Source/MQTTnet/Packets/MqttUnsubscribe.cs Vedi File

@@ -11,7 +11,7 @@ namespace MQTTnet.Packets
public override string ToString()
{
var topicFiltersText = string.Join(",", TopicFilters);
return "Unsubscribe: [PacketIdentifier=" + PacketIdentifier + "] [TopicFilters=" + topicFiltersText + "]";
return string.Concat("Unsubscribe: [PacketIdentifier=", PacketIdentifier, "] [TopicFilters=", topicFiltersText, "]");
}
}
}

+ 8
- 0
Source/MQTTnet/Protocol/MqttPubCompReasonCode.cs Vedi File

@@ -0,0 +1,8 @@
namespace MQTTnet.Protocol
{
public enum MqttPubCompReasonCode
{
Success = 0,
PacketIdentifierNotFound = 146
}
}

+ 15
- 0
Source/MQTTnet/Protocol/MqttPubRecReasonCode.cs Vedi File

@@ -0,0 +1,15 @@
namespace MQTTnet.Protocol
{
public enum MqttPubRecReasonCode
{
Success = 0,
NoMatchingSubscribers = 16,
UnspecifiedError = 128,
ImplementationSpecificError = 131,
NotAuthorized = 135,
TopicNameInvalid = 144,
PacketIdentifierInUse = 145,
QuotaExceeded = 151,
PayloadFormatInvalid = 153
}
}

+ 8
- 0
Source/MQTTnet/Protocol/MqttPubRelReasonCode.cs Vedi File

@@ -0,0 +1,8 @@
namespace MQTTnet.Protocol
{
public enum MqttPubRelReasonCode
{
Success = 0,
PacketIdentifierNotFound = 146
}
}

+ 9
- 0
Source/MQTTnet/Protocol/MqttRetainHandling.cs Vedi File

@@ -0,0 +1,9 @@
namespace MQTTnet.Protocol
{
public enum MqttRetainHandling
{
SendAtSubscribe = 0,
SendAtSubscribeIfNewSubscriptionOnly = 1,
DoNotSendOnSubscribe = 2
}
}

+ 18
- 0
Source/MQTTnet/Protocol/MqttSubscribeReasonCode.cs Vedi File

@@ -0,0 +1,18 @@
namespace MQTTnet.Protocol
{
public enum MqttSubscribeReasonCode
{
GrantedQoS0 = 0,
GrantedQoS1 = 1,
GrantedQoS2 = 2,
UnspecifiedError = 128,
ImplementationSpecificError = 131,
NotAuthorized = 135,
TopicFilterInvalid = 143,
PacketIdentifierInUse = 145,
QuotaExceeded = 151,
SharedSubscriptionsNotSupported = 158,
SubscriptionIdentifiersNotSupported = 161,
WildcardSubscriptionsNotSupported = 162
}
}

+ 19
- 0
Source/MQTTnet/TopicFilter.cs Vedi File

@@ -14,6 +14,25 @@ namespace MQTTnet

public MqttQualityOfServiceLevel QualityOfServiceLevel { get; set; }

#region Added in MQTTv5

/// <summary>
/// This is only available when using MQTT version 5.
/// </summary>
public bool? NoLocal { get; set; }

/// <summary>
/// This is only available when using MQTT version 5.
/// </summary>
public bool? RetainAsPublished { get; set; }

/// <summary>
/// This is only available when using MQTT version 5.
/// </summary>
public MqttRetainHandling? RetainHandling { get; set; }

#endregion

public override string ToString()
{
return Topic + "@" + QualityOfServiceLevel;


Caricamento…
Annulla
Salva