From 0f5fb8aa3a12f109d8534b6c6d8e81d55589584c Mon Sep 17 00:00:00 2001 From: Christian Kratky Date: Wed, 28 Nov 2018 21:11:23 +0100 Subject: [PATCH] Add more pacakges. --- Images/Logo_128x128.png | Bin 1183 -> 1269 bytes README.md | 5 +++-- .../Formatter/V500/MqttV500PacketDecoder.cs | 2 +- .../Formatter/V500/MqttV500PacketEncoder.cs | 10 ++++----- .../Formatter/V500/MqttV500PacketFormatter.cs | 3 ++- Source/MQTTnet/Packets/MqttConnAckPacket.cs | 4 ++-- Source/MQTTnet/Packets/MqttConnectPacket.cs | 2 +- Source/MQTTnet/Packets/MqttPubAckPacket.cs | 4 ++-- Source/MQTTnet/Packets/MqttPubCompPacket.cs | 14 +++++++++++-- .../Packets/MqttPubCompPacketProperties.cs | 11 ++++++++++ Source/MQTTnet/Packets/MqttPubRecPacket.cs | 14 +++++++++++-- .../Packets/MqttPubRecPacketProperties.cs | 11 ++++++++++ Source/MQTTnet/Packets/MqttPubRelPacket.cs | 14 +++++++++++-- .../Packets/MqttPubRelPacketProperties.cs | 11 ++++++++++ Source/MQTTnet/Packets/MqttPublishPacket.cs | 11 +++------- Source/MQTTnet/Packets/MqttSubAckPacket.cs | 12 +++++++++-- .../Packets/MqttSubAckPacketProperties.cs | 11 ++++++++++ Source/MQTTnet/Packets/MqttSubscribePacket.cs | 8 +++++++- .../Packets/MqttSubscribePacketProperties.cs | 11 ++++++++++ Source/MQTTnet/Packets/MqttUnsubAckPacket.cs | 2 +- Source/MQTTnet/Packets/MqttUnsubscribe.cs | 2 +- .../MQTTnet/Protocol/MqttPubCompReasonCode.cs | 8 ++++++++ .../MQTTnet/Protocol/MqttPubRecReasonCode.cs | 15 ++++++++++++++ .../MQTTnet/Protocol/MqttPubRelReasonCode.cs | 8 ++++++++ Source/MQTTnet/Protocol/MqttRetainHandling.cs | 9 +++++++++ .../Protocol/MqttSubscribeReasonCode.cs | 18 +++++++++++++++++ Source/MQTTnet/TopicFilter.cs | 19 ++++++++++++++++++ 27 files changed, 206 insertions(+), 33 deletions(-) create mode 100644 Source/MQTTnet/Packets/MqttPubCompPacketProperties.cs create mode 100644 Source/MQTTnet/Packets/MqttPubRecPacketProperties.cs create mode 100644 Source/MQTTnet/Packets/MqttPubRelPacketProperties.cs create mode 100644 Source/MQTTnet/Packets/MqttSubAckPacketProperties.cs create mode 100644 Source/MQTTnet/Packets/MqttSubscribePacketProperties.cs create mode 100644 Source/MQTTnet/Protocol/MqttPubCompReasonCode.cs create mode 100644 Source/MQTTnet/Protocol/MqttPubRecReasonCode.cs create mode 100644 Source/MQTTnet/Protocol/MqttPubRelReasonCode.cs create mode 100644 Source/MQTTnet/Protocol/MqttRetainHandling.cs create mode 100644 Source/MQTTnet/Protocol/MqttSubscribeReasonCode.cs diff --git a/Images/Logo_128x128.png b/Images/Logo_128x128.png index a528d7ce54a8fa545838b6ce8373d1bdf828436e..697acbf2be5de49921e0fe840fa9c4276485ddbb 100644 GIT binary patch literal 1269 zcmeAS@N?(olHy`uVBq!ia0vp^4Is?H1SEZ8zRdwrEa{HEjtmSN`?>!lvI6;>1s;*b z3=Dh+K$tP>S|=w^P@=>&q9iy!t)x7$D3zfgF*C13FE6!3!9>qc&qUZE;|S24Vow*x zkczmsGrarmScy1qUX`Qp`~KP4`#DTF@D>cfMQOI+?P*locvLH_^WUy{9P z44Wkn zvOzaa$MNorP5H*~gx&hHBlCtWN-vc*i+axHk!$#qklx3CVS=B&bo@jhp*`u_rj1H3 zx9(vS5`AhoA>)iY&w&cpOMBm}^{7(hZ*Xy~;c2y)7LC( zp0jT#HIrQ9QKg$7reZrKR3R`>j=A$#%>@Rb&?l-BUIc_SLanT6_*YncQ|{^GL*I6s z1X?t4y2B#pNLHvT`S}l=ch~QITR53xft z;*t!VTAzeGN;FnGELvp4Ce-_LCZp7+=d}wj?$d5Hxl9~fnMTuIpg3cARNU*PV(Y~z4C5YpLpOfYv?dX9LI@@pY z#NAet_ZBa?pYnlg=Pt*?45Cl=Oz#b^dGd;FE^~~?uNBijdf7g`to>_p^%oumXc`Vv ziA`Zs$pXgT&MkkX3pAu17O4RPQeS$3+|D^g43*-MOkYntHDUfB>Y=iU<<-Q~n(Qlz zKTh{}Vgz>0{)hV+#XrfxxXUFMfRYz59V<--hQ=CTXx!cXUZt@i?pC!lvI6;>1s;*b z3=DjSK$uZf!>a)(C|TkfQ4*Y=R#Ki=l*&+$n3-3imzP?iV4`QBXK1nbV$&y}K{B2$ zjv*CsZ>I&WyJIH6QmhrP@O{7UKUsmshQj4XmQGtFSH7EDCzm$$8)oOF|x#fjQ%h*~ANfzs4YPYXVnp)jY@B#_ylK{C@xIVrGff zy4Cm2UVgv-^(6+WEvtpL1h03>4}r)kGb`M?856khY!6p%*pEU+jV&v+wn#$xJ8T-* za%ZPs*tYUQTS&%duU0c-tu2v>OcEgw^*eMLewE*qmAhhZUQ!;hu=+gL-T0Lk(%f3j zv};rvj-3g6&wJ}jNXF%0i1HZ>Y@r#(i=AeR>hUh9TW$R-Zl(1ubC9&JKg8&V$&4oJ z>Q;xnuuE!vXDfQ^%!&(Xt(*w~P}xrmufA{Ie?7nVSM3*M75!`r=H$Nme(`sQ=&tV} z5G(#gFnnDnz4zr_$Jz6M;i0uumcmFotzxh{sm z_tD(5qEP3{OFDek`f?1;m3Al=`SmswCM$d3q2!j@aHtR0GXB{jy6gD=-&+|?GKBws zSsRmMcxjOC(l4)>J8DT!GYO5NyWXcT zMI^Mov!2Ny7P0WRpIQTJ*o%FWIUl5n-g=Y5v?H?B%=+hJMwu^pT)FFSG=EFK$GZ3L zl-n#97UbK$vR003tXmHeVJ#4?eSfBWLHVk3$9(&zVT>Be)wfo#yafggFzj!h)MZ`} z8@ll9LMLe;Ig=~5tY|kw#$v54mTNBjJ;QbPJTMj}NB>hVIKp*zHZT%_qCP;YGldWE zeE9}aZp6sr^nNmg;gCNcn99^Y*Eh@#1!{vhcF9$H#w|OeLGHcEXrf)RAH>WQb!awA zkGm@m@>IOM!{h~b6IF~fOw0&oWq|;(nA(c-hI3N{(q+PZ;tA-%%8*#EKC?YUHx3vIVCg!05!-BEC2ui diff --git a/README.md b/README.md index cb405dd..a187cc5 100644 --- a/README.md +++ b/README.md @@ -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 diff --git a/Source/MQTTnet/Formatter/V500/MqttV500PacketDecoder.cs b/Source/MQTTnet/Formatter/V500/MqttV500PacketDecoder.cs index 348afd6..c0b3531 100644 --- a/Source/MQTTnet/Formatter/V500/MqttV500PacketDecoder.cs +++ b/Source/MQTTnet/Formatter/V500/MqttV500PacketDecoder.cs @@ -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) diff --git a/Source/MQTTnet/Formatter/V500/MqttV500PacketEncoder.cs b/Source/MQTTnet/Formatter/V500/MqttV500PacketEncoder.cs index 9d236be..cb4d2a6 100644 --- a/Source/MQTTnet/Formatter/V500/MqttV500PacketEncoder.cs +++ b/Source/MQTTnet/Formatter/V500/MqttV500PacketEncoder.cs @@ -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); } diff --git a/Source/MQTTnet/Formatter/V500/MqttV500PacketFormatter.cs b/Source/MQTTnet/Formatter/V500/MqttV500PacketFormatter.cs index d95255f..f815129 100644 --- a/Source/MQTTnet/Formatter/V500/MqttV500PacketFormatter.cs +++ b/Source/MQTTnet/Formatter/V500/MqttV500PacketFormatter.cs @@ -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(applicationMessage.UserProperties) } }; } diff --git a/Source/MQTTnet/Packets/MqttConnAckPacket.cs b/Source/MQTTnet/Packets/MqttConnAckPacket.cs index 1a9aa66..e8caefa 100644 --- a/Source/MQTTnet/Packets/MqttConnAckPacket.cs +++ b/Source/MQTTnet/Packets/MqttConnAckPacket.cs @@ -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, "]"); } } } diff --git a/Source/MQTTnet/Packets/MqttConnectPacket.cs b/Source/MQTTnet/Packets/MqttConnectPacket.cs index 1fc5a42..c6b8e6e 100644 --- a/Source/MQTTnet/Packets/MqttConnectPacket.cs +++ b/Source/MQTTnet/Packets/MqttConnectPacket.cs @@ -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, "]"); } } } diff --git a/Source/MQTTnet/Packets/MqttPubAckPacket.cs b/Source/MQTTnet/Packets/MqttPubAckPacket.cs index ad29f07..2af1642 100644 --- a/Source/MQTTnet/Packets/MqttPubAckPacket.cs +++ b/Source/MQTTnet/Packets/MqttPubAckPacket.cs @@ -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, "]"); } } } diff --git a/Source/MQTTnet/Packets/MqttPubCompPacket.cs b/Source/MQTTnet/Packets/MqttPubCompPacket.cs index e9ea18e..0798819 100644 --- a/Source/MQTTnet/Packets/MqttPubCompPacket.cs +++ b/Source/MQTTnet/Packets/MqttPubCompPacket.cs @@ -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, "]"); } } } diff --git a/Source/MQTTnet/Packets/MqttPubCompPacketProperties.cs b/Source/MQTTnet/Packets/MqttPubCompPacketProperties.cs new file mode 100644 index 0000000..35e040f --- /dev/null +++ b/Source/MQTTnet/Packets/MqttPubCompPacketProperties.cs @@ -0,0 +1,11 @@ +using System.Collections.Generic; + +namespace MQTTnet.Packets +{ + public class MqttPubCompPacketProperties + { + public string ReasonString { get; set; } + + public List UserProperties { get; set; } + } +} diff --git a/Source/MQTTnet/Packets/MqttPubRecPacket.cs b/Source/MQTTnet/Packets/MqttPubRecPacket.cs index 0184d6b..e462ce8 100644 --- a/Source/MQTTnet/Packets/MqttPubRecPacket.cs +++ b/Source/MQTTnet/Packets/MqttPubRecPacket.cs @@ -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, "]"); } } } diff --git a/Source/MQTTnet/Packets/MqttPubRecPacketProperties.cs b/Source/MQTTnet/Packets/MqttPubRecPacketProperties.cs new file mode 100644 index 0000000..0cd7225 --- /dev/null +++ b/Source/MQTTnet/Packets/MqttPubRecPacketProperties.cs @@ -0,0 +1,11 @@ +using System.Collections.Generic; + +namespace MQTTnet.Packets +{ + public class MqttPubRecPacketProperties + { + public string ReasonString { get; set; } + + public List UserProperties { get; set; } + } +} diff --git a/Source/MQTTnet/Packets/MqttPubRelPacket.cs b/Source/MQTTnet/Packets/MqttPubRelPacket.cs index bb37655..cf2c71b 100644 --- a/Source/MQTTnet/Packets/MqttPubRelPacket.cs +++ b/Source/MQTTnet/Packets/MqttPubRelPacket.cs @@ -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, "]"); } } } diff --git a/Source/MQTTnet/Packets/MqttPubRelPacketProperties.cs b/Source/MQTTnet/Packets/MqttPubRelPacketProperties.cs new file mode 100644 index 0000000..aa9625d --- /dev/null +++ b/Source/MQTTnet/Packets/MqttPubRelPacketProperties.cs @@ -0,0 +1,11 @@ +using System.Collections.Generic; + +namespace MQTTnet.Packets +{ + public class MqttPubRelPacketProperties + { + public string ReasonString { get; set; } + + public List UserProperties { get; set; } + } +} diff --git a/Source/MQTTnet/Packets/MqttPublishPacket.cs b/Source/MQTTnet/Packets/MqttPublishPacket.cs index e1644d0..2f20b14 100644 --- a/Source/MQTTnet/Packets/MqttPublishPacket.cs +++ b/Source/MQTTnet/Packets/MqttPublishPacket.cs @@ -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, "]"); } } } diff --git a/Source/MQTTnet/Packets/MqttSubAckPacket.cs b/Source/MQTTnet/Packets/MqttSubAckPacket.cs index 05e18b2..45b0e0c 100644 --- a/Source/MQTTnet/Packets/MqttSubAckPacket.cs +++ b/Source/MQTTnet/Packets/MqttSubAckPacket.cs @@ -8,12 +8,20 @@ namespace MQTTnet.Packets { public ushort? PacketIdentifier { get; set; } - public IList SubscribeReturnCodes { get; } = new List(); + public List SubscribeReturnCodes { get; } = new List(); + + #region Added in MQTTv5 + + public List 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, "]"); } } } diff --git a/Source/MQTTnet/Packets/MqttSubAckPacketProperties.cs b/Source/MQTTnet/Packets/MqttSubAckPacketProperties.cs new file mode 100644 index 0000000..74d3e7f --- /dev/null +++ b/Source/MQTTnet/Packets/MqttSubAckPacketProperties.cs @@ -0,0 +1,11 @@ +using System.Collections.Generic; + +namespace MQTTnet.Packets +{ + public class MqttSubAckPacketProperties + { + public string ReasonString { get; set; } + + public List UserProperties { get; set; } + } +} diff --git a/Source/MQTTnet/Packets/MqttSubscribePacket.cs b/Source/MQTTnet/Packets/MqttSubscribePacket.cs index 60086c4..c185f35 100644 --- a/Source/MQTTnet/Packets/MqttSubscribePacket.cs +++ b/Source/MQTTnet/Packets/MqttSubscribePacket.cs @@ -9,10 +9,16 @@ namespace MQTTnet.Packets public IList TopicFilters { get; set; } = new List(); + #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, "]"); } } } diff --git a/Source/MQTTnet/Packets/MqttSubscribePacketProperties.cs b/Source/MQTTnet/Packets/MqttSubscribePacketProperties.cs new file mode 100644 index 0000000..34f58f2 --- /dev/null +++ b/Source/MQTTnet/Packets/MqttSubscribePacketProperties.cs @@ -0,0 +1,11 @@ +using System.Collections.Generic; + +namespace MQTTnet.Packets +{ + public class MqttSubscribePacketProperties + { + public uint? SubscriptionIdentifier { get; set; } + + public List UserProperties { get; set; } + } +} diff --git a/Source/MQTTnet/Packets/MqttUnsubAckPacket.cs b/Source/MQTTnet/Packets/MqttUnsubAckPacket.cs index ab5f9f6..8b78b53 100644 --- a/Source/MQTTnet/Packets/MqttUnsubAckPacket.cs +++ b/Source/MQTTnet/Packets/MqttUnsubAckPacket.cs @@ -6,7 +6,7 @@ public override string ToString() { - return "UnsubAck: [PacketIdentifier=" + PacketIdentifier + "]"; + return string.Concat("UnsubAck: [PacketIdentifier=", PacketIdentifier, "]"); } } } diff --git a/Source/MQTTnet/Packets/MqttUnsubscribe.cs b/Source/MQTTnet/Packets/MqttUnsubscribe.cs index 63895f1..de56386 100644 --- a/Source/MQTTnet/Packets/MqttUnsubscribe.cs +++ b/Source/MQTTnet/Packets/MqttUnsubscribe.cs @@ -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, "]"); } } } diff --git a/Source/MQTTnet/Protocol/MqttPubCompReasonCode.cs b/Source/MQTTnet/Protocol/MqttPubCompReasonCode.cs new file mode 100644 index 0000000..9c23927 --- /dev/null +++ b/Source/MQTTnet/Protocol/MqttPubCompReasonCode.cs @@ -0,0 +1,8 @@ +namespace MQTTnet.Protocol +{ + public enum MqttPubCompReasonCode + { + Success = 0, + PacketIdentifierNotFound = 146 + } +} diff --git a/Source/MQTTnet/Protocol/MqttPubRecReasonCode.cs b/Source/MQTTnet/Protocol/MqttPubRecReasonCode.cs new file mode 100644 index 0000000..b64eac2 --- /dev/null +++ b/Source/MQTTnet/Protocol/MqttPubRecReasonCode.cs @@ -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 + } +} diff --git a/Source/MQTTnet/Protocol/MqttPubRelReasonCode.cs b/Source/MQTTnet/Protocol/MqttPubRelReasonCode.cs new file mode 100644 index 0000000..d71da68 --- /dev/null +++ b/Source/MQTTnet/Protocol/MqttPubRelReasonCode.cs @@ -0,0 +1,8 @@ +namespace MQTTnet.Protocol +{ + public enum MqttPubRelReasonCode + { + Success = 0, + PacketIdentifierNotFound = 146 + } +} diff --git a/Source/MQTTnet/Protocol/MqttRetainHandling.cs b/Source/MQTTnet/Protocol/MqttRetainHandling.cs new file mode 100644 index 0000000..8ee50cc --- /dev/null +++ b/Source/MQTTnet/Protocol/MqttRetainHandling.cs @@ -0,0 +1,9 @@ +namespace MQTTnet.Protocol +{ + public enum MqttRetainHandling + { + SendAtSubscribe = 0, + SendAtSubscribeIfNewSubscriptionOnly = 1, + DoNotSendOnSubscribe = 2 + } +} diff --git a/Source/MQTTnet/Protocol/MqttSubscribeReasonCode.cs b/Source/MQTTnet/Protocol/MqttSubscribeReasonCode.cs new file mode 100644 index 0000000..e3f2c0f --- /dev/null +++ b/Source/MQTTnet/Protocol/MqttSubscribeReasonCode.cs @@ -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 + } +} diff --git a/Source/MQTTnet/TopicFilter.cs b/Source/MQTTnet/TopicFilter.cs index 7eebbc2..9461562 100644 --- a/Source/MQTTnet/TopicFilter.cs +++ b/Source/MQTTnet/TopicFilter.cs @@ -14,6 +14,25 @@ namespace MQTTnet public MqttQualityOfServiceLevel QualityOfServiceLevel { get; set; } + #region Added in MQTTv5 + + /// + /// This is only available when using MQTT version 5. + /// + public bool? NoLocal { get; set; } + + /// + /// This is only available when using MQTT version 5. + /// + public bool? RetainAsPublished { get; set; } + + /// + /// This is only available when using MQTT version 5. + /// + public MqttRetainHandling? RetainHandling { get; set; } + + #endregion + public override string ToString() { return Topic + "@" + QualityOfServiceLevel;