diff --git a/Source/MQTTnet.Extensions.Rpc/Options/TopicGeneration/TopicGenerationContext.cs b/Source/MQTTnet.Extensions.Rpc/Options/TopicGeneration/TopicGenerationContext.cs index cd82c52..39110bb 100644 --- a/Source/MQTTnet.Extensions.Rpc/Options/TopicGeneration/TopicGenerationContext.cs +++ b/Source/MQTTnet.Extensions.Rpc/Options/TopicGeneration/TopicGenerationContext.cs @@ -7,6 +7,14 @@ namespace MQTTnet.Extensions.Rpc.Options.TopicGeneration { public string MethodName { get; set; } + /// + /// Gets or sets the quality of service level. + /// The Quality of Service (QoS) level is an agreement between the sender of a message and the receiver of a message that defines the guarantee of delivery for a specific message. + /// There are 3 QoS levels in MQTT: + /// - At most once (0): Message gets delivered no time, once or multiple times. + /// - At least once (1): Message gets delivered at least once (one time or more often). + /// - Exactly once (2): Message gets delivered exactly once (It's ensured that the message only comes once). + /// public MqttQualityOfServiceLevel QualityOfServiceLevel { get; set; } public IMqttClient MqttClient { get; set; } diff --git a/Source/MQTTnet/Client/Connecting/MqttClientAuthenticateResult.cs b/Source/MQTTnet/Client/Connecting/MqttClientAuthenticateResult.cs index 7419fae..ecb1293 100644 --- a/Source/MQTTnet/Client/Connecting/MqttClientAuthenticateResult.cs +++ b/Source/MQTTnet/Client/Connecting/MqttClientAuthenticateResult.cs @@ -7,6 +7,10 @@ namespace MQTTnet.Client.Connecting // TODO: Consider renaming this to _MqttClientConnectResult_ public class MqttClientAuthenticateResult { + /// + /// Gets or sets the result code. + /// Hint: MQTT 5 feature only. + /// public MqttClientConnectResultCode ResultCode { get; set; } public bool IsSessionPresent { get; set; } @@ -17,18 +21,34 @@ namespace MQTTnet.Client.Connecting public string AssignedClientIdentifier { get; set; } + /// + /// Gets or sets the authentication method. + /// Hint: MQTT 5 feature only. + /// public string AuthenticationMethod { get; set; } + /// + /// Gets or sets the authentication data. + /// Hint: MQTT 5 feature only. + /// public byte[] AuthenticationData { get; set; } public uint? MaximumPacketSize { get; set; } + /// + /// Gets or sets the reason string. + /// Hint: MQTT 5 feature only. + /// public string ReasonString { get; set; } public ushort? ReceiveMaximum { get; set; } public MqttQualityOfServiceLevel MaximumQoS { get; set; } + /// + /// Gets or sets the response information. + /// Hint: MQTT 5 feature only. + /// public string ResponseInformation { get; set; } public ushort? TopicAliasMaximum { get; set; } @@ -39,10 +59,25 @@ namespace MQTTnet.Client.Connecting public uint? SessionExpiryInterval { get; set; } + /// + /// Gets or sets a value indicating whether the subscription identifiers are available or not. + /// Hint: MQTT 5 feature only. + /// public bool? SubscriptionIdentifiersAvailable { get; set; } + /// + /// Gets or sets a value indicating whether the shared subscriptions are available or not. + /// Hint: MQTT 5 feature only. + /// public bool? SharedSubscriptionAvailable { get; set; } + /// + /// Gets or sets the user properties. + /// In MQTT 5, user properties are basic UTF-8 string key-value pairs that you can append to almost every type of MQTT packet. + /// As long as you don’t exceed the maximum message size, you can use an unlimited number of user properties to add metadata to MQTT messages and pass information between publisher, broker, and subscriber. + /// The feature is very similar to the HTTP header concept. + /// Hint: MQTT 5 feature only. + /// public List UserProperties { get; set; } } } diff --git a/Source/MQTTnet/Client/Connecting/MqttClientConnectedEventArgs.cs b/Source/MQTTnet/Client/Connecting/MqttClientConnectedEventArgs.cs index e7f97b9..02cd47f 100644 --- a/Source/MQTTnet/Client/Connecting/MqttClientConnectedEventArgs.cs +++ b/Source/MQTTnet/Client/Connecting/MqttClientConnectedEventArgs.cs @@ -9,6 +9,10 @@ namespace MQTTnet.Client.Connecting AuthenticateResult = authenticateResult ?? throw new ArgumentNullException(nameof(authenticateResult)); } + /// + /// Gets the authentication result. + /// Hint: MQTT 5 feature only. + /// public MqttClientAuthenticateResult AuthenticateResult { get; } } } diff --git a/Source/MQTTnet/Client/Disconnecting/MqttClientDisconnectOptions.cs b/Source/MQTTnet/Client/Disconnecting/MqttClientDisconnectOptions.cs index f9fdf28..7f8c644 100644 --- a/Source/MQTTnet/Client/Disconnecting/MqttClientDisconnectOptions.cs +++ b/Source/MQTTnet/Client/Disconnecting/MqttClientDisconnectOptions.cs @@ -2,8 +2,16 @@ { public sealed class MqttClientDisconnectOptions { + /// + /// Gets or sets the reason code. + /// Hint: MQTT 5 feature only. + /// public MqttClientDisconnectReason ReasonCode { get; set; } = MqttClientDisconnectReason.NormalDisconnection; + /// + /// Gets or sets the reason string. + /// Hint: MQTT 5 feature only. + /// public string ReasonString { get; set; } } } diff --git a/Source/MQTTnet/Client/Disconnecting/MqttClientDisconnectedEventArgs.cs b/Source/MQTTnet/Client/Disconnecting/MqttClientDisconnectedEventArgs.cs index 5e2317c..932f009 100644 --- a/Source/MQTTnet/Client/Disconnecting/MqttClientDisconnectedEventArgs.cs +++ b/Source/MQTTnet/Client/Disconnecting/MqttClientDisconnectedEventArgs.cs @@ -19,8 +19,16 @@ namespace MQTTnet.Client.Disconnecting public Exception Exception { get; } + /// + /// Gets the authentication result. + /// Hint: MQTT 5 feature only. + /// public MqttClientAuthenticateResult AuthenticateResult { get; } + /// + /// Gets or sets the reason. + /// Hint: MQTT 5 feature only. + /// public MqttClientDisconnectReason Reason { get; set; } [Obsolete("Please use 'Reason' instead. This property will be removed in the future!")] diff --git a/Source/MQTTnet/Client/ExtendedAuthenticationExchange/MqttExtendedAuthenticationExchangeContext.cs b/Source/MQTTnet/Client/ExtendedAuthenticationExchange/MqttExtendedAuthenticationExchangeContext.cs index 9e88f03..082e9a8 100644 --- a/Source/MQTTnet/Client/ExtendedAuthenticationExchange/MqttExtendedAuthenticationExchangeContext.cs +++ b/Source/MQTTnet/Client/ExtendedAuthenticationExchange/MqttExtendedAuthenticationExchangeContext.cs @@ -20,14 +20,37 @@ namespace MQTTnet.Client.ExtendedAuthenticationExchange Client = client ?? throw new ArgumentNullException(nameof(client)); } + /// + /// Gets the reason code. + /// Hint: MQTT 5 feature only. + /// public MqttAuthenticateReasonCode ReasonCode { get; } + /// + /// Gets the reason string. + /// Hint: MQTT 5 feature only. + /// public string ReasonString { get; } + /// + /// Gets the authentication method. + /// Hint: MQTT 5 feature only. + /// public string AuthenticationMethod { get; } + /// + /// Gets the authentication data. + /// Hint: MQTT 5 feature only. + /// public byte[] AuthenticationData { get; } + /// + /// Gets the user properties. + /// In MQTT 5, user properties are basic UTF-8 string key-value pairs that you can append to almost every type of MQTT packet. + /// As long as you don’t exceed the maximum message size, you can use an unlimited number of user properties to add metadata to MQTT messages and pass information between publisher, broker, and subscriber. + /// The feature is very similar to the HTTP header concept. + /// Hint: MQTT 5 feature only. + /// public List UserProperties { get; } public IMqttClient Client { get; } diff --git a/Source/MQTTnet/Client/ExtendedAuthenticationExchange/MqttExtendedAuthenticationExchangeData.cs b/Source/MQTTnet/Client/ExtendedAuthenticationExchange/MqttExtendedAuthenticationExchangeData.cs index 8a49b08..29f3821 100644 --- a/Source/MQTTnet/Client/ExtendedAuthenticationExchange/MqttExtendedAuthenticationExchangeData.cs +++ b/Source/MQTTnet/Client/ExtendedAuthenticationExchange/MqttExtendedAuthenticationExchangeData.cs @@ -6,12 +6,33 @@ namespace MQTTnet.Client.ExtendedAuthenticationExchange { public class MqttExtendedAuthenticationExchangeData { + /// + /// Gets or sets the reason code. + /// Hint: MQTT 5 feature only. + /// public MqttAuthenticateReasonCode ReasonCode { get; set; } + /// + /// Gets or sets the reason string. + /// Hint: MQTT 5 feature only. + /// public string ReasonString { get; set; } + /// + /// Gets or sets the authentication data. + /// Authentication data is binary information used to transmit multiple iterations of cryptographic secrets of protocol steps. + /// The content of the authentication data is highly dependent on the specific implementation of the authentication method. + /// Hint: MQTT 5 feature only. + /// public byte[] AuthenticationData { get; set; } + /// + /// Gets or sets the user properties. + /// In MQTT 5, user properties are basic UTF-8 string key-value pairs that you can append to almost every type of MQTT packet. + /// As long as you don’t exceed the maximum message size, you can use an unlimited number of user properties to add metadata to MQTT messages and pass information between publisher, broker, and subscriber. + /// The feature is very similar to the HTTP header concept. + /// Hint: MQTT 5 feature only. + /// public List UserProperties { get; } } } diff --git a/Source/MQTTnet/Client/IMqttClient.cs b/Source/MQTTnet/Client/IMqttClient.cs index 58cfa0c..394ec8d 100644 --- a/Source/MQTTnet/Client/IMqttClient.cs +++ b/Source/MQTTnet/Client/IMqttClient.cs @@ -13,18 +13,38 @@ namespace MQTTnet.Client public interface IMqttClient : IApplicationMessageReceiver, IApplicationMessagePublisher, IDisposable { bool IsConnected { get; } + IMqttClientOptions Options { get; } + /// + /// Gets or sets the connected handler that is fired after the client has connected to the server successfully. + /// Hint: Initialize handlers before you connect the client to avoid issues. + /// IMqttClientConnectedHandler ConnectedHandler { get; set; } + /// + /// Gets or sets the disconnected handler that is fired after the client has disconnected from the server. + /// Hint: Initialize handlers before you connect the client to avoid issues. + /// IMqttClientDisconnectedHandler DisconnectedHandler { get; set; } Task ConnectAsync(IMqttClientOptions options, CancellationToken cancellationToken); + Task DisconnectAsync(MqttClientDisconnectOptions options, CancellationToken cancellationToken); + Task PingAsync(CancellationToken cancellationToken); + /// + /// Sends extended authentication data. + /// Hint: MQTT 5 feature only. + /// + /// The extended data. + /// A cancellation token to stop the task. + /// A representing any asynchronous operation. Task SendExtendedAuthenticationExchangeDataAsync(MqttExtendedAuthenticationExchangeData data, CancellationToken cancellationToken); + Task SubscribeAsync(MqttClientSubscribeOptions options, CancellationToken cancellationToken); + Task UnsubscribeAsync(MqttClientUnsubscribeOptions options, CancellationToken cancellationToken); } } \ No newline at end of file diff --git a/Source/MQTTnet/Client/IMqttClientFactory.cs b/Source/MQTTnet/Client/IMqttClientFactory.cs index b256e74..4bbb79a 100644 --- a/Source/MQTTnet/Client/IMqttClientFactory.cs +++ b/Source/MQTTnet/Client/IMqttClientFactory.cs @@ -1,5 +1,4 @@ -using System; -using MQTTnet.Adapter; +using MQTTnet.Adapter; using MQTTnet.Diagnostics; using MQTTnet.LowLevelClient; diff --git a/Source/MQTTnet/Client/Options/IMqttClientOptions.cs b/Source/MQTTnet/Client/Options/IMqttClientOptions.cs index 8bf89ee..1ef462a 100644 --- a/Source/MQTTnet/Client/Options/IMqttClientOptions.cs +++ b/Source/MQTTnet/Client/Options/IMqttClientOptions.cs @@ -9,26 +9,104 @@ namespace MQTTnet.Client.Options { public interface IMqttClientOptions { + /// + /// Gets the client identifier. + /// Hint: This identifier needs to be unique over all used clients / devices on the broker to avoid connection issues. + /// string ClientId { get; } + + /// + /// Gets a value indicating whether clean sessions are used or not. + /// When a client connects to a broker it can connect using either a non persistent connection (clean session) or a persistent connection. + /// With a non persistent connection the broker doesn't store any subscription information or undelivered messages for the client. + /// This mode is ideal when the client only publishes messages. + /// It can also connect as a durable client using a persistent connection. + /// In this mode, the broker will store subscription information, and undelivered messages for the client. + /// bool CleanSession { get; } + IMqttClientCredentials Credentials { get; } + IMqttExtendedAuthenticationExchangeHandler ExtendedAuthenticationExchangeHandler { get; } + MqttProtocolVersion ProtocolVersion { get; } + IMqttClientChannelOptions ChannelOptions { get; } TimeSpan CommunicationTimeout { get; } + + /// + /// Gets the keep alive period. + /// The connection is normally left open by the client so that is can send and receive data at any time. + /// If no data flows over an open connection for a certain time period then the client will generate a PINGREQ and expect to receive a PINGRESP from the broker. + /// This message exchange confirms that the connection is open and working. + /// This period is known as the keep alive period. + /// TimeSpan KeepAlivePeriod { get; } + + /// + /// Gets the last will message. + /// In MQTT, you use the last will message feature to notify other clients about an ungracefully disconnected client. + /// MqttApplicationMessage WillMessage { get; } + + /// + /// Gets the will delay interval. + /// This is the time between the client disconnect and the time the will message will be sent. + /// uint? WillDelayInterval { get; } + /// + /// Gets the authentication method. + /// Hint: MQTT 5 feature only. + /// string AuthenticationMethod { get; } + + /// + /// Gets the authentication data. + /// Hint: MQTT 5 feature only. + /// byte[] AuthenticationData { get; } + uint? MaximumPacketSize { get; } + + /// + /// Gets the receive maximum. + /// This gives the maximum length of the receive messages. + /// ushort? ReceiveMaximum { get; } + + /// + /// Gets the request problem information. + /// Hint: MQTT 5 feature only. + /// bool? RequestProblemInformation { get; } + + /// + /// Gets the request response information. + /// Hint: MQTT 5 feature only. + /// bool? RequestResponseInformation { get; } + + /// + /// Gets the session expiry interval. + /// The time after a session expires when it's not actively used. + /// uint? SessionExpiryInterval { get; } + + /// + /// Gets the topic alias maximum. + /// This gives the maximum length of the topic alias. + /// ushort? TopicAliasMaximum { get; } + + /// + /// Gets or sets the user properties. + /// In MQTT 5, user properties are basic UTF-8 string key-value pairs that you can append to almost every type of MQTT packet. + /// As long as you don’t exceed the maximum message size, you can use an unlimited number of user properties to add metadata to MQTT messages and pass information between publisher, broker, and subscriber. + /// The feature is very similar to the HTTP header concept. + /// Hint: MQTT 5 feature only. + /// List UserProperties { get; set; } IMqttPacketInspector PacketInspector { get; set; } diff --git a/Source/MQTTnet/Client/Options/MqttClientOptions.cs b/Source/MQTTnet/Client/Options/MqttClientOptions.cs index ad93716..d67410a 100644 --- a/Source/MQTTnet/Client/Options/MqttClientOptions.cs +++ b/Source/MQTTnet/Client/Options/MqttClientOptions.cs @@ -9,28 +9,104 @@ namespace MQTTnet.Client.Options { public class MqttClientOptions : IMqttClientOptions { + /// + /// Gets the client identifier. + /// Hint: This identifier needs to be unique over all used clients / devices on the broker to avoid connection issues. + /// public string ClientId { get; set; } = Guid.NewGuid().ToString("N"); + + /// + /// Gets or sets a value indicating whether clean sessions are used or not. + /// When a client connects to a broker it can connect using either a non persistent connection (clean session) or a persistent connection. + /// With a non persistent connection the broker doesn't store any subscription information or undelivered messages for the client. + /// This mode is ideal when the client only publishes messages. + /// It can also connect as a durable client using a persistent connection. + /// In this mode, the broker will store subscription information, and undelivered messages for the client. + /// public bool CleanSession { get; set; } = true; + public IMqttClientCredentials Credentials { get; set; } + public IMqttExtendedAuthenticationExchangeHandler ExtendedAuthenticationExchangeHandler { get; set; } + public MqttProtocolVersion ProtocolVersion { get; set; } = MqttProtocolVersion.V311; public IMqttClientChannelOptions ChannelOptions { get; set; } + public TimeSpan CommunicationTimeout { get; set; } = TimeSpan.FromSeconds(10); + + /// + /// Gets or sets the keep alive period. + /// The connection is normally left open by the client so that is can send and receive data at any time. + /// If no data flows over an open connection for a certain time period then the client will generate a PINGREQ and expect to receive a PINGRESP from the broker. + /// This message exchange confirms that the connection is open and working. + /// This period is known as the keep alive period. + /// public TimeSpan KeepAlivePeriod { get; set; } = TimeSpan.FromSeconds(15); + /// + /// Gets or sets the last will message. + /// In MQTT, you use the last will message feature to notify other clients about an ungracefully disconnected client. + /// public MqttApplicationMessage WillMessage { get; set; } + + /// + /// Gets or sets the will delay interval. + /// This is the time between the client disconnect and the time the will message will be sent. + /// public uint? WillDelayInterval { get; set; } + /// + /// Gets or sets the authentication method. + /// Hint: MQTT 5 feature only. + /// public string AuthenticationMethod { get; set; } + + /// + /// Gets or sets the authentication data. + /// Hint: MQTT 5 feature only. + /// public byte[] AuthenticationData { get; set; } public uint? MaximumPacketSize { get; set; } + + /// + /// Gets or sets the receive maximum. + /// This gives the maximum length of the receive messages. + /// public ushort? ReceiveMaximum { get; set; } + + /// + /// Gets or sets the request problem information. + /// Hint: MQTT 5 feature only. + /// public bool? RequestProblemInformation { get; set; } + + /// + /// Gets or sets the request response information. + /// Hint: MQTT 5 feature only. + /// public bool? RequestResponseInformation { get; set; } + + /// + /// Gets or sets the session expiry interval. + /// The time after a session expires when it's not actively used. + /// public uint? SessionExpiryInterval { get; set; } + + /// + /// Gets or sets the topic alias maximum. + /// This gives the maximum length of the topic alias. + /// public ushort? TopicAliasMaximum { get; set; } + + /// + /// Gets or sets the user properties. + /// In MQTT 5, user properties are basic UTF-8 string key-value pairs that you can append to almost every type of MQTT packet. + /// As long as you don’t exceed the maximum message size, you can use an unlimited number of user properties to add metadata to MQTT messages and pass information between publisher, broker, and subscriber. + /// The feature is very similar to the HTTP header concept. + /// Hint: MQTT 5 feature only. + /// public List UserProperties { get; set; } public IMqttPacketInspector PacketInspector { get; set; } diff --git a/Source/MQTTnet/Client/Publishing/MqttClientPublishResult.cs b/Source/MQTTnet/Client/Publishing/MqttClientPublishResult.cs index 15035ec..429f130 100644 --- a/Source/MQTTnet/Client/Publishing/MqttClientPublishResult.cs +++ b/Source/MQTTnet/Client/Publishing/MqttClientPublishResult.cs @@ -8,10 +8,25 @@ namespace MQTTnet.Client.Publishing { public ushort? PacketIdentifier { get; set; } + /// + /// Gets or sets the reason code. + /// Hint: MQTT 5 feature only. + /// public MqttClientPublishReasonCode ReasonCode { get; set; } = MqttClientPublishReasonCode.Success; + /// + /// Gets or sets the reason string. + /// Hint: MQTT 5 feature only. + /// public string ReasonString { get; set; } + /// + /// Gets or sets the user properties. + /// In MQTT 5, user properties are basic UTF-8 string key-value pairs that you can append to almost every type of MQTT packet. + /// As long as you don’t exceed the maximum message size, you can use an unlimited number of user properties to add metadata to MQTT messages and pass information between publisher, broker, and subscriber. + /// The feature is very similar to the HTTP header concept. + /// Hint: MQTT 5 feature only. + /// public List UserProperties { get; set; } } } diff --git a/Source/MQTTnet/Client/Subscribing/MqttClientSubscribeOptions.cs b/Source/MQTTnet/Client/Subscribing/MqttClientSubscribeOptions.cs index 42c38e1..2c43c42 100644 --- a/Source/MQTTnet/Client/Subscribing/MqttClientSubscribeOptions.cs +++ b/Source/MQTTnet/Client/Subscribing/MqttClientSubscribeOptions.cs @@ -5,10 +5,28 @@ namespace MQTTnet.Client.Subscribing { public class MqttClientSubscribeOptions { + /// + /// Gets or sets a list of topic filters the client wants to subscribe to. + /// Topic filters can include regular topics or wild cards. + /// public List TopicFilters { get; set; } = new List(); + /// + /// Gets or sets the subscription identifier. + /// The client can specify a subscription identifier when subscribing. + /// The broker will establish and store the mapping relationship between this subscription and subscription identifier when successfully create or modify subscription. + /// The broker will return the subscription identifier associated with this PUBLISH packet and the PUBLISH packet to the client when need to forward PUBLISH packets matching this subscription to this client. + /// Hint: MQTT 5 feature only. + /// public uint? SubscriptionIdentifier { get; set; } + /// + /// Gets or sets the user properties. + /// In MQTT 5, user properties are basic UTF-8 string key-value pairs that you can append to almost every type of MQTT packet. + /// As long as you don’t exceed the maximum message size, you can use an unlimited number of user properties to add metadata to MQTT messages and pass information between publisher, broker, and subscriber. + /// The feature is very similar to the HTTP header concept. + /// Hint: MQTT 5 feature only. + /// public List UserProperties { get; set; } } } diff --git a/Source/MQTTnet/Client/Subscribing/MqttClientSubscribeOptionsBuilder.cs b/Source/MQTTnet/Client/Subscribing/MqttClientSubscribeOptionsBuilder.cs index 97b5b77..14d2ad6 100644 --- a/Source/MQTTnet/Client/Subscribing/MqttClientSubscribeOptionsBuilder.cs +++ b/Source/MQTTnet/Client/Subscribing/MqttClientSubscribeOptionsBuilder.cs @@ -9,6 +9,13 @@ namespace MQTTnet.Client.Subscribing { private readonly MqttClientSubscribeOptions _subscribeOptions = new MqttClientSubscribeOptions(); + /// + /// Adds the user property to the subscribe options. + /// Hint: MQTT 5 feature only. + /// + /// The property name. + /// The property value. + /// A new instance of the class. public MqttClientSubscribeOptionsBuilder WithUserProperty(string name, string value) { if (name == null) throw new ArgumentNullException(nameof(name)); @@ -27,7 +34,6 @@ namespace MQTTnet.Client.Subscribing public MqttClientSubscribeOptionsBuilder WithSubscriptionIdentifier(uint? subscriptionIdentifier) { _subscribeOptions.SubscriptionIdentifier = subscriptionIdentifier; - return this; } diff --git a/Source/MQTTnet/Client/Subscribing/MqttClientSubscribeResultItem.cs b/Source/MQTTnet/Client/Subscribing/MqttClientSubscribeResultItem.cs index 65f15c4..3e2d27f 100644 --- a/Source/MQTTnet/Client/Subscribing/MqttClientSubscribeResultItem.cs +++ b/Source/MQTTnet/Client/Subscribing/MqttClientSubscribeResultItem.cs @@ -10,8 +10,16 @@ namespace MQTTnet.Client.Subscribing ResultCode = resultCode; } + /// + /// Gets or sets the topic filter. + /// The topic filter can contain topics and wildcards. + /// public MqttTopicFilter TopicFilter { get; } + /// + /// Gets or sets the result code. + /// Hint: MQTT 5 feature only. + /// public MqttClientSubscribeResultCode ResultCode { get; } } } diff --git a/Source/MQTTnet/Client/Unsubscribing/MqttClientUnsubscribeOptions.cs b/Source/MQTTnet/Client/Unsubscribing/MqttClientUnsubscribeOptions.cs index 73c21ef..09a4ce2 100644 --- a/Source/MQTTnet/Client/Unsubscribing/MqttClientUnsubscribeOptions.cs +++ b/Source/MQTTnet/Client/Unsubscribing/MqttClientUnsubscribeOptions.cs @@ -5,8 +5,19 @@ namespace MQTTnet.Client.Unsubscribing { public class MqttClientUnsubscribeOptions { + /// + /// Gets or sets a list of topic filters the client wants to unsubscribe from. + /// Topic filters can include regular topics or wild cards. + /// public List TopicFilters { get; set; } = new List(); + /// + /// Gets or sets the user properties. + /// In MQTT 5, user properties are basic UTF-8 string key-value pairs that you can append to almost every type of MQTT packet. + /// As long as you don’t exceed the maximum message size, you can use an unlimited number of user properties to add metadata to MQTT messages and pass information between publisher, broker, and subscriber. + /// The feature is very similar to the HTTP header concept. + /// Hint: MQTT 5 feature only. + /// public List UserProperties { get; set; } = new List(); } } diff --git a/Source/MQTTnet/Client/Unsubscribing/MqttClientUnsubscribeOptionsBuilder.cs b/Source/MQTTnet/Client/Unsubscribing/MqttClientUnsubscribeOptionsBuilder.cs index 8516243..a7f022e 100644 --- a/Source/MQTTnet/Client/Unsubscribing/MqttClientUnsubscribeOptionsBuilder.cs +++ b/Source/MQTTnet/Client/Unsubscribing/MqttClientUnsubscribeOptionsBuilder.cs @@ -8,6 +8,13 @@ namespace MQTTnet.Client.Unsubscribing { private readonly MqttClientUnsubscribeOptions _unsubscribeOptions = new MqttClientUnsubscribeOptions(); + /// + /// Adds the user property to the unsubscribe options. + /// Hint: MQTT 5 feature only. + /// + /// The property name. + /// The property value. + /// A new instance of the class. public MqttClientUnsubscribeOptionsBuilder WithUserProperty(string name, string value) { if (name is null) throw new ArgumentNullException(nameof(name)); @@ -16,6 +23,12 @@ namespace MQTTnet.Client.Unsubscribing return WithUserProperty(new MqttUserProperty(name, value)); } + /// + /// Adds the user property to the unsubscribe options. + /// Hint: MQTT 5 feature only. + /// + /// The user property. + /// A new instance of the class. public MqttClientUnsubscribeOptionsBuilder WithUserProperty(MqttUserProperty userProperty) { if (userProperty is null) throw new ArgumentNullException(nameof(userProperty)); diff --git a/Source/MQTTnet/Client/Unsubscribing/MqttClientUnsubscribeResultItem.cs b/Source/MQTTnet/Client/Unsubscribing/MqttClientUnsubscribeResultItem.cs index 755ee43..065fb7f 100644 --- a/Source/MQTTnet/Client/Unsubscribing/MqttClientUnsubscribeResultItem.cs +++ b/Source/MQTTnet/Client/Unsubscribing/MqttClientUnsubscribeResultItem.cs @@ -10,8 +10,16 @@ namespace MQTTnet.Client.Unsubscribing ReasonCode = reasonCode; } + /// + /// Gets or sets the topic filter. + /// The topic filter can contain topics and wildcards. + /// public string TopicFilter { get; } + /// + /// Gets or sets the result code. + /// Hint: MQTT 5 feature only. + /// public MqttClientUnsubscribeResultCode ReasonCode { get; } } } \ No newline at end of file diff --git a/Source/MQTTnet/IApplicationMessageReceiver.cs b/Source/MQTTnet/IApplicationMessageReceiver.cs index 4e47485..a44470d 100644 --- a/Source/MQTTnet/IApplicationMessageReceiver.cs +++ b/Source/MQTTnet/IApplicationMessageReceiver.cs @@ -4,6 +4,10 @@ namespace MQTTnet { public interface IApplicationMessageReceiver { + /// + /// Gets or sets the application message received handler that is fired every time a new message is received on the client's subscriptions. + /// Hint: Initialize handlers before you connect the client to avoid issues. + /// IMqttApplicationMessageReceivedHandler ApplicationMessageReceivedHandler { get; set; } } } diff --git a/Source/MQTTnet/MqttApplicationMessage.cs b/Source/MQTTnet/MqttApplicationMessage.cs index 6522d42..99068fe 100644 --- a/Source/MQTTnet/MqttApplicationMessage.cs +++ b/Source/MQTTnet/MqttApplicationMessage.cs @@ -6,28 +6,99 @@ namespace MQTTnet { public class MqttApplicationMessage { + /// + /// Gets or sets the MQTT topic. + /// In MQTT, the word topic refers to an UTF-8 string that the broker uses to filter messages for each connected client. + /// The topic consists of one or more topic levels. Each topic level is separated by a forward slash (topic level separator). + /// public string Topic { get; set; } + /// + /// Gets or sets the payload. + /// The payload is the data bytes sent via the MQTT protocol. + /// public byte[] Payload { get; set; } + /// + /// Gets or sets the quality of service level. + /// The Quality of Service (QoS) level is an agreement between the sender of a message and the receiver of a message that defines the guarantee of delivery for a specific message. + /// There are 3 QoS levels in MQTT: + /// - At most once (0): Message gets delivered no time, once or multiple times. + /// - At least once (1): Message gets delivered at least once (one time or more often). + /// - Exactly once (2): Message gets delivered exactly once (It's ensured that the message only comes once). + /// public MqttQualityOfServiceLevel QualityOfServiceLevel { get; set; } + /// + /// Gets or sets a value indicating whether the message should be retained or not. + /// A retained message is a normal MQTT message with the retained flag set to true. + /// The broker stores the last retained message and the corresponding QoS for that topic. + /// public bool Retain { get; set; } + /// + /// Gets or sets the user properties. + /// In MQTT 5, user properties are basic UTF-8 string key-value pairs that you can append to almost every type of MQTT packet. + /// As long as you don’t exceed the maximum message size, you can use an unlimited number of user properties to add metadata to MQTT messages and pass information between publisher, broker, and subscriber. + /// The feature is very similar to the HTTP header concept. + /// Hint: MQTT 5 feature only. + /// public List UserProperties { get; set; } + /// + /// Gets or sets the content type. + /// The content type must be a UTF-8 encoded string. The content type value identifies the kind of UTF-8 encoded payload. + /// public string ContentType { get; set; } + /// + /// Gets or sets the response topic. + /// In MQTT 5 the ability to publish a response topic was added in the publish message which allows you to implement the request/response pattern between clients that is common in web applications. + /// Hint: MQTT 5 feature only. + /// public string ResponseTopic { get; set; } + /// + /// Gets or sets the payload format indicator. + /// The payload format indicator is part of any MQTT packet that can contain a payload. The indicator is an optional byte value. + /// A value of 0 indicates an “unspecified byte stream”. + /// A value of 1 indicates a "UTF-8 encoded payload". + /// If no payload format indicator is provided, the default value is 0. + /// Hint: MQTT 5 feature only. + /// public MqttPayloadFormatIndicator? PayloadFormatIndicator { get; set; } + /// + /// Gets or sets the message expiry interval. + /// A client can set the message expiry interval in seconds for each PUBLISH message individually. + /// This interval defines the period of time that the broker stores the PUBLISH message for any matching subscribers that are not currently connected. + /// When no message expiry interval is set, the broker must store the message for matching subscribers indefinitely. + /// When the retained=true option is set on the PUBLISH message, this interval also defines how long a message is retained on a topic. + /// Hint: MQTT 5 feature only. + /// public uint? MessageExpiryInterval { get; set; } + /// + /// Gets or sets the topic alias. + /// Topic aliases were introduced are a mechanism for reducing the size of published packets by reducing the size of the topic field. + /// Hint: MQTT 5 feature only. + /// public ushort? TopicAlias { get; set; } + /// + /// Gets or sets the correlation data. + /// In order for the sender to know what sent message the response refers to it can also send correlation data with the published message. + /// Hint: MQTT 5 feature only. + /// public byte[] CorrelationData { get; set; } + /// + /// Gets or sets the subscription identifiers. + /// The client can specify a subscription identifier when subscribing. + /// The broker will establish and store the mapping relationship between this subscription and subscription identifier when successfully create or modify subscription. + /// The broker will return the subscription identifier associated with this PUBLISH packet and the PUBLISH packet to the client when need to forward PUBLISH packets matching this subscription to this client. + /// Hint: MQTT 5 feature only. + /// public List SubscriptionIdentifiers { get; set; } } } diff --git a/Source/MQTTnet/MqttApplicationMessageBuilder.cs b/Source/MQTTnet/MqttApplicationMessageBuilder.cs index 7e48531..f2fc0cd 100644 --- a/Source/MQTTnet/MqttApplicationMessageBuilder.cs +++ b/Source/MQTTnet/MqttApplicationMessageBuilder.cs @@ -11,17 +11,99 @@ namespace MQTTnet { public class MqttApplicationMessageBuilder { + /// + /// The quality of service level. + /// The Quality of Service (QoS) level is an agreement between the sender of a message and the receiver of a message that defines the guarantee of delivery for a specific message. + /// There are 3 QoS levels in MQTT: + /// - At most once (0): Message gets delivered no time, once or multiple times. + /// - At least once (1): Message gets delivered at least once (one time or more often). + /// - Exactly once (2): Message gets delivered exactly once (It's ensured that the message only comes once). + /// private MqttQualityOfServiceLevel _qualityOfServiceLevel = MqttQualityOfServiceLevel.AtMostOnce; + + /// + /// The MQTT topic. + /// In MQTT, the word topic refers to an UTF-8 string that the broker uses to filter messages for each connected client. + /// The topic consists of one or more topic levels. Each topic level is separated by a forward slash (topic level separator). + /// private string _topic; + + /// + /// The payload. + /// The payload is the data bytes sent via the MQTT protocol. + /// private byte[] _payload; + + /// + /// A value indicating whether the message should be retained or not. + /// A retained message is a normal MQTT message with the retained flag set to true. + /// The broker stores the last retained message and the corresponding QoS for that topic. + /// private bool _retain; + + /// + /// The content type. + /// The content type must be a UTF-8 encoded string. The content type value identifies the kind of UTF-8 encoded payload. + /// private string _contentType; + + /// + /// The response topic. + /// In MQTT 5 the ability to publish a response topic was added in the publish message which allows you to implement the request/response pattern between clients that is common in web applications. + /// Hint: MQTT 5 feature only. + /// private string _responseTopic; + + /// + /// The correlation data. + /// In order for the sender to know what sent message the response refers to it can also send correlation data with the published message. + /// Hint: MQTT 5 feature only. + /// private byte[] _correlationData; + + /// + /// The topic alias. + /// Topic aliases were introduced are a mechanism for reducing the size of published packets by reducing the size of the topic field. + /// Hint: MQTT 5 feature only. + /// private ushort? _topicAlias; + + /// + /// The subscription identifiers. + /// The client can specify a subscription identifier when subscribing. + /// The broker will establish and store the mapping relationship between this subscription and subscription identifier when successfully create or modify subscription. + /// The broker will return the subscription identifier associated with this PUBLISH packet and the PUBLISH packet to the client when need to forward PUBLISH packets matching this subscription to this client. + /// Hint: MQTT 5 feature only. + /// private List _subscriptionIdentifiers; + + /// + /// The message expiry interval. + /// A client can set the message expiry interval in seconds for each PUBLISH message individually. + /// This interval defines the period of time that the broker stores the PUBLISH message for any matching subscribers that are not currently connected. + /// When no message expiry interval is set, the broker must store the message for matching subscribers indefinitely. + /// When the retained=true option is set on the PUBLISH message, this interval also defines how long a message is retained on a topic. + /// Hint: MQTT 5 feature only. + /// private uint? _messageExpiryInterval; + + /// + /// The payload format indicator. + /// The payload format indicator is part of any MQTT packet that can contain a payload. The indicator is an optional byte value. + /// A value of 0 indicates an “unspecified byte stream”. + /// A value of 1 indicates a "UTF-8 encoded payload". + /// If no payload format indicator is provided, the default value is 0. + /// Hint: MQTT 5 feature only. + /// private MqttPayloadFormatIndicator? _payloadFormatIndicator; + + /// + /// The user properties. + /// In MQTT 5, user properties are basic UTF-8 string key-value pairs that you can append to almost every type of MQTT packet. + /// As long as you don’t exceed the maximum message size, you can use an unlimited number of user properties to add metadata to MQTT messages and pass information between publisher, broker, and subscriber. + /// The feature is very similar to the HTTP header concept. + /// + /// Hint: MQTT 5 feature only. private List _userProperties; public MqttApplicationMessageBuilder WithTopic(string topic) @@ -139,8 +221,12 @@ namespace MQTTnet } /// - /// This is only supported when using MQTTv5. + /// Adds the user property to the message. + /// Hint: MQTT 5 feature only. /// + /// The property name. + /// The property value. + /// A new instance of the class. public MqttApplicationMessageBuilder WithUserProperty(string name, string value) { if (_userProperties == null) @@ -153,8 +239,10 @@ namespace MQTTnet } /// - /// This is only supported when using MQTTv5. + /// Adds the content type to the message. + /// Hint: MQTT 5 feature only. /// + /// A new instance of the class. public MqttApplicationMessageBuilder WithContentType(string contentType) { _contentType = contentType; @@ -162,8 +250,11 @@ namespace MQTTnet } /// - /// This is only supported when using MQTTv5. + /// Adds the response topic to the message. + /// Hint: MQTT 5 feature only. /// + /// The response topic. + /// A new instance of the class. public MqttApplicationMessageBuilder WithResponseTopic(string responseTopic) { _responseTopic = responseTopic; @@ -171,8 +262,11 @@ namespace MQTTnet } /// - /// This is only supported when using MQTTv5. + /// Adds the correlation data to the message. + /// Hint: MQTT 5 feature only. /// + /// The correlation data. + /// A new instance of the class. public MqttApplicationMessageBuilder WithCorrelationData(byte[] correlationData) { _correlationData = correlationData; @@ -180,8 +274,11 @@ namespace MQTTnet } /// - /// This is only supported when using MQTTv5. + /// Adds the topic alias to the message. + /// Hint: MQTT 5 feature only. /// + /// The topic alias. + /// A new instance of the class. public MqttApplicationMessageBuilder WithTopicAlias(ushort topicAlias) { _topicAlias = topicAlias; @@ -189,8 +286,11 @@ namespace MQTTnet } /// - /// This is only supported when using MQTTv5. + /// Adds the subscription identifier to the message. + /// Hint: MQTT 5 feature only. /// + /// The subscription identifier. + /// A new instance of the class. public MqttApplicationMessageBuilder WithSubscriptionIdentifier(uint subscriptionIdentifier) { if (_subscriptionIdentifiers == null) @@ -203,8 +303,11 @@ namespace MQTTnet } /// - /// This is only supported when using MQTTv5. + /// Adds the message expiry interval to the message. + /// Hint: MQTT 5 feature only. /// + /// The message expiry interval. + /// A new instance of the class. public MqttApplicationMessageBuilder WithMessageExpiryInterval(uint messageExpiryInterval) { _messageExpiryInterval = messageExpiryInterval; @@ -212,8 +315,11 @@ namespace MQTTnet } /// - /// This is only supported when using MQTTv5. + /// Adds the payload format indicator to the message. + /// Hint: MQTT 5 feature only. /// + /// The payload format indicator. + /// A new instance of the class. public MqttApplicationMessageBuilder WithPayloadFormatIndicator(MqttPayloadFormatIndicator payloadFormatIndicator) { _payloadFormatIndicator = payloadFormatIndicator; diff --git a/Source/MQTTnet/MqttApplicationMessageReceivedEventArgs.cs b/Source/MQTTnet/MqttApplicationMessageReceivedEventArgs.cs index a27f9c7..533f4df 100644 --- a/Source/MQTTnet/MqttApplicationMessageReceivedEventArgs.cs +++ b/Source/MQTTnet/MqttApplicationMessageReceivedEventArgs.cs @@ -10,6 +10,10 @@ namespace MQTTnet ApplicationMessage = applicationMessage ?? throw new ArgumentNullException(nameof(applicationMessage)); } + /// + /// Gets the client identifier. + /// Hint: This identifier needs to be unique over all used clients / devices on the broker to avoid connection issues. + /// public string ClientId { get; } public MqttApplicationMessage ApplicationMessage { get; } diff --git a/Source/MQTTnet/MqttTopicFilter.cs b/Source/MQTTnet/MqttTopicFilter.cs index 66ea94a..fda60e0 100644 --- a/Source/MQTTnet/MqttTopicFilter.cs +++ b/Source/MQTTnet/MqttTopicFilter.cs @@ -10,22 +10,38 @@ namespace MQTTnet public class MqttTopicFilter { + /// + /// Gets or sets the MQTT topic. + /// In MQTT, the word topic refers to an UTF-8 string that the broker uses to filter messages for each connected client. + /// The topic consists of one or more topic levels. Each topic level is separated by a forward slash (topic level separator). + /// public string Topic { get; set; } + /// + /// Gets or sets the quality of service level. + /// The Quality of Service (QoS) level is an agreement between the sender of a message and the receiver of a message that defines the guarantee of delivery for a specific message. + /// There are 3 QoS levels in MQTT: + /// - At most once (0): Message gets delivered no time, once or multiple times. + /// - At least once (1): Message gets delivered at least once (one time or more often). + /// - Exactly once (2): Message gets delivered exactly once (It's ensured that the message only comes once). + /// public MqttQualityOfServiceLevel QualityOfServiceLevel { get; set; } /// - /// This is only supported when using MQTTv5. + /// Gets or sets a value indicating whether to not send messages originating on this client (noLocal) or not. /// + /// Hint: MQTT 5 feature only. public bool? NoLocal { get; set; } /// - /// This is only supported when using MQTTv5. + /// Gets or sets a value indicating whether messages are retained as published or not. + /// Hint: MQTT 5 feature only. /// public bool? RetainAsPublished { get; set; } /// - /// This is only supported when using MQTTv5. + /// Gets or sets the retain handling. + /// Hint: MQTT 5 feature only. /// public MqttRetainHandling? RetainHandling { get; set; } diff --git a/Source/MQTTnet/MqttTopicFilterBuilder.cs b/Source/MQTTnet/MqttTopicFilterBuilder.cs index 3bb75ab..0143c41 100644 --- a/Source/MQTTnet/MqttTopicFilterBuilder.cs +++ b/Source/MQTTnet/MqttTopicFilterBuilder.cs @@ -11,7 +11,21 @@ namespace MQTTnet public class MqttTopicFilterBuilder { + /// + /// The quality of service level. + /// The Quality of Service (QoS) level is an agreement between the sender of a message and the receiver of a message that defines the guarantee of delivery for a specific message. + /// There are 3 QoS levels in MQTT: + /// - At most once (0): Message gets delivered no time, once or multiple times. + /// - At least once (1): Message gets delivered at least once (one time or more often). + /// - Exactly once (2): Message gets delivered exactly once (It's ensured that the message only comes once). + /// MqttQualityOfServiceLevel _qualityOfServiceLevel = MqttQualityOfServiceLevel.AtMostOnce; + + /// + /// The MQTT topic. + /// In MQTT, the word topic refers to an UTF-8 string that the broker uses to filter messages for each connected client. + /// The topic consists of one or more topic levels. Each topic level is separated by a forward slash (topic level separator). + /// string _topic; bool? _noLocal; bool? _retainAsPublished; diff --git a/Source/MQTTnet/Server/CheckSubscriptionsResult.cs b/Source/MQTTnet/Server/CheckSubscriptionsResult.cs index b6e7dbd..eb66f17 100644 --- a/Source/MQTTnet/Server/CheckSubscriptionsResult.cs +++ b/Source/MQTTnet/Server/CheckSubscriptionsResult.cs @@ -8,6 +8,14 @@ namespace MQTTnet.Server public bool IsSubscribed { get; set; } + /// + /// Gets or sets the quality of service level. + /// The Quality of Service (QoS) level is an agreement between the sender of a message and the receiver of a message that defines the guarantee of delivery for a specific message. + /// There are 3 QoS levels in MQTT: + /// - At most once (0): Message gets delivered no time, once or multiple times. + /// - At least once (1): Message gets delivered at least once (one time or more often). + /// - Exactly once (2): Message gets delivered exactly once (It's ensured that the message only comes once). + /// public MqttQualityOfServiceLevel QualityOfServiceLevel { get; set; } } } diff --git a/Source/MQTTnet/Server/IMqttClientSession.cs b/Source/MQTTnet/Server/IMqttClientSession.cs index d7db2b1..f522df6 100644 --- a/Source/MQTTnet/Server/IMqttClientSession.cs +++ b/Source/MQTTnet/Server/IMqttClientSession.cs @@ -4,6 +4,10 @@ namespace MQTTnet.Server { public interface IMqttClientSession { + /// + /// Gets the client identifier. + /// Hint: This identifier needs to be unique over all used clients / devices on the broker to avoid connection issues. + /// string ClientId { get; } Task StopAsync(); diff --git a/Source/MQTTnet/Server/IMqttServerOptions.cs b/Source/MQTTnet/Server/IMqttServerOptions.cs index 233048e..cd0cd40 100644 --- a/Source/MQTTnet/Server/IMqttServerOptions.cs +++ b/Source/MQTTnet/Server/IMqttServerOptions.cs @@ -4,6 +4,10 @@ namespace MQTTnet.Server { public interface IMqttServerOptions { + /// + /// Gets the client identifier. + /// Hint: This identifier needs to be unique over all used clients / devices on the broker to avoid connection issues. + /// string ClientId { get; set; } bool EnablePersistentSessions { get; } diff --git a/Source/MQTTnet/Server/IMqttServerPersistedSession.cs b/Source/MQTTnet/Server/IMqttServerPersistedSession.cs index 9ca4076..a7b015e 100644 --- a/Source/MQTTnet/Server/IMqttServerPersistedSession.cs +++ b/Source/MQTTnet/Server/IMqttServerPersistedSession.cs @@ -5,14 +5,26 @@ namespace MQTTnet.Server { public interface IMqttServerPersistedSession { + /// + /// Gets the client identifier. + /// Hint: This identifier needs to be unique over all used clients / devices on the broker to avoid connection issues. + /// string ClientId { get; } IDictionary Items { get; } IList Subscriptions { get; } + /// + /// Gets the last will message. + /// In MQTT, you use the last will message feature to notify other clients about an ungracefully disconnected client. + /// MqttApplicationMessage WillMessage { get; } + /// + /// Gets the will delay interval. + /// This is the time between the client disconnect and the time the will message will be sent. + /// uint? WillDelayInterval { get; } DateTime? SessionExpiryTimestamp { get; } diff --git a/Source/MQTTnet/Server/MqttApplicationMessageInterceptorContext.cs b/Source/MQTTnet/Server/MqttApplicationMessageInterceptorContext.cs index cde9a85..f606a57 100644 --- a/Source/MQTTnet/Server/MqttApplicationMessageInterceptorContext.cs +++ b/Source/MQTTnet/Server/MqttApplicationMessageInterceptorContext.cs @@ -18,6 +18,10 @@ namespace MQTTnet.Server /// public IMqttNetScopedLogger Logger { get; } + /// + /// Gets the client identifier. + /// Hint: This identifier needs to be unique over all used clients / devices on the broker to avoid connection issues. + /// public string ClientId { get; } public MqttApplicationMessage ApplicationMessage { get; set; } diff --git a/Source/MQTTnet/Server/MqttClientMessageQueueInterceptorContext.cs b/Source/MQTTnet/Server/MqttClientMessageQueueInterceptorContext.cs index 209f8c0..881666e 100644 --- a/Source/MQTTnet/Server/MqttClientMessageQueueInterceptorContext.cs +++ b/Source/MQTTnet/Server/MqttClientMessageQueueInterceptorContext.cs @@ -20,6 +20,14 @@ namespace MQTTnet.Server public bool AcceptEnqueue { get; set; } = true; + /// + /// Gets or sets the supscription quality of service level. + /// The Quality of Service (QoS) level is an agreement between the sender of a message and the receiver of a message that defines the guarantee of delivery for a specific message. + /// There are 3 QoS levels in MQTT: + /// - At most once (0): Message gets delivered no time, once or multiple times. + /// - At least once (1): Message gets delivered at least once (one time or more often). + /// - Exactly once (2): Message gets delivered exactly once (It's ensured that the message only comes once). + /// public MqttQualityOfServiceLevel SubscriptionQualityOfServiceLevel { get; set; } } } diff --git a/Source/MQTTnet/Server/MqttConnectionValidatorContext.cs b/Source/MQTTnet/Server/MqttConnectionValidatorContext.cs index 9a5b8b9..e9d6aeb 100644 --- a/Source/MQTTnet/Server/MqttConnectionValidatorContext.cs +++ b/Source/MQTTnet/Server/MqttConnectionValidatorContext.cs @@ -21,6 +21,10 @@ namespace MQTTnet.Server SessionItems = sessionItems; } + /// + /// Gets the client identifier. + /// Hint: This identifier needs to be unique over all used clients / devices on the broker to avoid connection issues. + /// public string ClientId => _connectPacket.ClientId; public string Endpoint => _clientAdapter.Endpoint; @@ -37,30 +41,88 @@ namespace MQTTnet.Server public string Password => Encoding.UTF8.GetString(RawPassword ?? new byte[0]); + /// + /// Gets or sets the will delay interval. + /// This is the time between the client disconnect and the time the will message will be sent. + /// public MqttApplicationMessage WillMessage => _connectPacket?.WillMessage; + /// + /// Gets or sets a value indicating whether clean sessions are used or not. + /// When a client connects to a broker it can connect using either a non persistent connection (clean session) or a persistent connection. + /// With a non persistent connection the broker doesn't store any subscription information or undelivered messages for the client. + /// This mode is ideal when the client only publishes messages. + /// It can also connect as a durable client using a persistent connection. + /// In this mode, the broker will store subscription information, and undelivered messages for the client. + /// public bool? CleanSession => _connectPacket?.CleanSession; + /// + /// Gets or sets the keep alive period. + /// The connection is normally left open by the client so that is can send and receive data at any time. + /// If no data flows over an open connection for a certain time period then the client will generate a PINGREQ and expect to receive a PINGRESP from the broker. + /// This message exchange confirms that the connection is open and working. + /// This period is known as the keep alive period. + /// public ushort? KeepAlivePeriod => _connectPacket?.KeepAlivePeriod; + /// + /// Gets or sets the user properties. + /// In MQTT 5, user properties are basic UTF-8 string key-value pairs that you can append to almost every type of MQTT packet. + /// As long as you don’t exceed the maximum message size, you can use an unlimited number of user properties to add metadata to MQTT messages and pass information between publisher, broker, and subscriber. + /// The feature is very similar to the HTTP header concept. + /// Hint: MQTT 5 feature only. + /// public List UserProperties => _connectPacket?.Properties?.UserProperties; + /// + /// Gets or sets the authentication data. + /// Hint: MQTT 5 feature only. + /// public byte[] AuthenticationData => _connectPacket?.Properties?.AuthenticationData; + /// + /// Gets or sets the authentication method. + /// Hint: MQTT 5 feature only. + /// public string AuthenticationMethod => _connectPacket?.Properties?.AuthenticationMethod; public uint? MaximumPacketSize => _connectPacket?.Properties?.MaximumPacketSize; + /// + /// Gets or sets the receive maximum. + /// This gives the maximum length of the receive messages. + /// public ushort? ReceiveMaximum => _connectPacket?.Properties?.ReceiveMaximum; + /// + /// Gets or sets the topic alias maximum. + /// This gives the maximum length of the topic alias. + /// public ushort? TopicAliasMaximum => _connectPacket?.Properties?.TopicAliasMaximum; + /// + /// Gets the request problem information. + /// Hint: MQTT 5 feature only. + /// public bool? RequestProblemInformation => _connectPacket?.Properties?.RequestProblemInformation; + /// + /// Gets the request response information. + /// Hint: MQTT 5 feature only. + /// public bool? RequestResponseInformation => _connectPacket?.Properties?.RequestResponseInformation; + /// + /// Gets the session expiry interval. + /// The time after a session expires when it's not actively used. + /// public uint? SessionExpiryInterval => _connectPacket?.Properties?.SessionExpiryInterval; + /// + /// Gets or sets the will delay interval. + /// This is the time between the client disconnect and the time the will message will be sent. + /// public uint? WillDelayInterval => _connectPacket?.Properties?.WillDelayInterval; /// @@ -79,14 +141,26 @@ namespace MQTTnet.Server } /// - /// This is used for MQTTv5 only. When a MQTTv3 client connects the enum value must be one which is + /// Gets or sets the reason code. When a MQTTv3 client connects the enum value must be one which is /// also supported in MQTTv3. Otherwise the connection attempt will fail because not all codes can be /// converted properly. + /// Hint: MQTT 5 feature only. /// public MqttConnectReasonCode ReasonCode { get; set; } = MqttConnectReasonCode.Success; + /// + /// Gets or sets the response user properties. + /// In MQTT 5, user properties are basic UTF-8 string key-value pairs that you can append to almost every type of MQTT packet. + /// As long as you don’t exceed the maximum message size, you can use an unlimited number of user properties to add metadata to MQTT messages and pass information between publisher, broker, and subscriber. + /// The feature is very similar to the HTTP header concept. + /// Hint: MQTT 5 feature only. + /// public List ResponseUserProperties { get; set; } + /// + /// Gets or sets the response authentication data. + /// Hint: MQTT 5 feature only. + /// public byte[] ResponseAuthenticationData { get; set; } public string AssignedClientIdentifier { get; set; } diff --git a/Source/MQTTnet/Server/MqttQueuedApplicationMessage.cs b/Source/MQTTnet/Server/MqttQueuedApplicationMessage.cs index 635894b..5ca163d 100644 --- a/Source/MQTTnet/Server/MqttQueuedApplicationMessage.cs +++ b/Source/MQTTnet/Server/MqttQueuedApplicationMessage.cs @@ -11,6 +11,14 @@ namespace MQTTnet.Server public bool IsRetainedMessage { get; set; } + /// + /// Gets or sets the subscription quality of service level. + /// The Quality of Service (QoS) level is an agreement between the sender of a message and the receiver of a message that defines the guarantee of delivery for a specific message. + /// There are 3 QoS levels in MQTT: + /// - At most once (0): Message gets delivered no time, once or multiple times. + /// - At least once (1): Message gets delivered at least once (one time or more often). + /// - Exactly once (2): Message gets delivered exactly once (It's ensured that the message only comes once). + /// public MqttQualityOfServiceLevel SubscriptionQualityOfServiceLevel { get; set; } [Obsolete("Use 'SubscriptionQualityOfServiceLevel' instead.")] diff --git a/Source/MQTTnet/Server/MqttServerClientConnectedEventArgs.cs b/Source/MQTTnet/Server/MqttServerClientConnectedEventArgs.cs index 71c42c3..88f0c55 100644 --- a/Source/MQTTnet/Server/MqttServerClientConnectedEventArgs.cs +++ b/Source/MQTTnet/Server/MqttServerClientConnectedEventArgs.cs @@ -9,6 +9,10 @@ namespace MQTTnet.Server ClientId = clientId ?? throw new ArgumentNullException(nameof(clientId)); } + /// + /// Gets the client identifier. + /// Hint: This identifier needs to be unique over all used clients / devices on the broker to avoid connection issues. + /// public string ClientId { get; } } } diff --git a/Source/MQTTnet/Server/MqttServerClientDisconnectedEventArgs.cs b/Source/MQTTnet/Server/MqttServerClientDisconnectedEventArgs.cs index 9e74274..d2e7fe5 100644 --- a/Source/MQTTnet/Server/MqttServerClientDisconnectedEventArgs.cs +++ b/Source/MQTTnet/Server/MqttServerClientDisconnectedEventArgs.cs @@ -9,7 +9,11 @@ namespace MQTTnet.Server ClientId = clientId ?? throw new ArgumentNullException(nameof(clientId)); DisconnectType = disconnectType; } - + + /// + /// Gets the client identifier. + /// Hint: This identifier needs to be unique over all used clients / devices on the broker to avoid connection issues. + /// public string ClientId { get; } public MqttClientDisconnectType DisconnectType { get; } diff --git a/Source/MQTTnet/Server/MqttServerClientSubscribedTopicEventArgs.cs b/Source/MQTTnet/Server/MqttServerClientSubscribedTopicEventArgs.cs index 94d6e26..3586b73 100644 --- a/Source/MQTTnet/Server/MqttServerClientSubscribedTopicEventArgs.cs +++ b/Source/MQTTnet/Server/MqttServerClientSubscribedTopicEventArgs.cs @@ -10,8 +10,16 @@ namespace MQTTnet.Server TopicFilter = topicFilter ?? throw new ArgumentNullException(nameof(topicFilter)); } + /// + /// Gets the client identifier. + /// Hint: This identifier needs to be unique over all used clients / devices on the broker to avoid connection issues. + /// public string ClientId { get; } + /// + /// Gets the topic filter. + /// The topic filter can contain topics and wildcards. + /// public MqttTopicFilter TopicFilter { get; } } } diff --git a/Source/MQTTnet/Server/MqttServerClientUnsubscribedTopicEventArgs.cs b/Source/MQTTnet/Server/MqttServerClientUnsubscribedTopicEventArgs.cs index bb78bb2..8ed1264 100644 --- a/Source/MQTTnet/Server/MqttServerClientUnsubscribedTopicEventArgs.cs +++ b/Source/MQTTnet/Server/MqttServerClientUnsubscribedTopicEventArgs.cs @@ -10,8 +10,16 @@ namespace MQTTnet.Server TopicFilter = topicFilter ?? throw new ArgumentNullException(nameof(topicFilter)); } + /// + /// Gets the client identifier. + /// Hint: This identifier needs to be unique over all used clients / devices on the broker to avoid connection issues. + /// public string ClientId { get; } + /// + /// Gets or sets the topic filter. + /// The topic filter can contain topics and wildcards. + /// public string TopicFilter { get; } } } diff --git a/Source/MQTTnet/Server/MqttServerOptions.cs b/Source/MQTTnet/Server/MqttServerOptions.cs index 31f56e5..ab52813 100644 --- a/Source/MQTTnet/Server/MqttServerOptions.cs +++ b/Source/MQTTnet/Server/MqttServerOptions.cs @@ -8,6 +8,10 @@ namespace MQTTnet.Server public MqttServerTlsTcpEndpointOptions TlsEndpointOptions { get; } = new MqttServerTlsTcpEndpointOptions(); + /// + /// Gets or sets the client identifier. + /// Hint: This identifier needs to be unique over all used clients / devices on the broker to avoid connection issues. + /// public string ClientId { get; set; } public bool EnablePersistentSessions { get; set; } diff --git a/Source/MQTTnet/Server/MqttSubscriptionInterceptorContext.cs b/Source/MQTTnet/Server/MqttSubscriptionInterceptorContext.cs index 0d800c8..cc186e5 100644 --- a/Source/MQTTnet/Server/MqttSubscriptionInterceptorContext.cs +++ b/Source/MQTTnet/Server/MqttSubscriptionInterceptorContext.cs @@ -11,8 +11,16 @@ namespace MQTTnet.Server SessionItems = sessionItems; } + /// + /// Gets the client identifier. + /// Hint: This identifier needs to be unique over all used clients / devices on the broker to avoid connection issues. + /// public string ClientId { get; } + /// + /// Gets or sets the topic filter. + /// The topic filter can contain topics and wildcards. + /// public MqttTopicFilter TopicFilter { get; set; } /// diff --git a/Source/MQTTnet/Server/MqttUnsubscriptionInterceptorContext.cs b/Source/MQTTnet/Server/MqttUnsubscriptionInterceptorContext.cs index b33cbac..e5f8d75 100644 --- a/Source/MQTTnet/Server/MqttUnsubscriptionInterceptorContext.cs +++ b/Source/MQTTnet/Server/MqttUnsubscriptionInterceptorContext.cs @@ -11,8 +11,17 @@ namespace MQTTnet.Server SessionItems = sessionItems; } + /// + /// Gets the client identifier. + /// Hint: This identifier needs to be unique over all used clients / devices on the broker to avoid connection issues. + /// public string ClientId { get; } + /// + /// Gets or sets the MQTT topic. + /// In MQTT, the word topic refers to an UTF-8 string that the broker uses to filter messages for each connected client. + /// The topic consists of one or more topic levels. Each topic level is separated by a forward slash (topic level separator). + /// public string Topic { get; set; } /// diff --git a/Source/MQTTnet/Server/Status/IMqttClientStatus.cs b/Source/MQTTnet/Server/Status/IMqttClientStatus.cs index d7debdc..c080b51 100644 --- a/Source/MQTTnet/Server/Status/IMqttClientStatus.cs +++ b/Source/MQTTnet/Server/Status/IMqttClientStatus.cs @@ -6,6 +6,10 @@ namespace MQTTnet.Server.Status { public interface IMqttClientStatus { + /// + /// Gets the client identifier. + /// Hint: This identifier needs to be unique over all used clients / devices on the broker to avoid connection issues. + /// string ClientId { get; } string Endpoint { get; } diff --git a/Source/MQTTnet/Server/Status/IMqttSessionStatus.cs b/Source/MQTTnet/Server/Status/IMqttSessionStatus.cs index 2ff996b..115da13 100644 --- a/Source/MQTTnet/Server/Status/IMqttSessionStatus.cs +++ b/Source/MQTTnet/Server/Status/IMqttSessionStatus.cs @@ -5,6 +5,10 @@ namespace MQTTnet.Server.Status { public interface IMqttSessionStatus { + /// + /// Gets the client identifier. + /// Hint: This identifier needs to be unique over all used clients / devices on the broker to avoid connection issues. + /// string ClientId { get; } long PendingApplicationMessagesCount { get; } diff --git a/Source/MQTTnet/Server/Status/MqttClientStatus.cs b/Source/MQTTnet/Server/Status/MqttClientStatus.cs index 9acfea3..eca5d1a 100644 --- a/Source/MQTTnet/Server/Status/MqttClientStatus.cs +++ b/Source/MQTTnet/Server/Status/MqttClientStatus.cs @@ -14,6 +14,10 @@ namespace MQTTnet.Server.Status _connection = connection ?? throw new ArgumentNullException(nameof(connection)); } + /// + /// Gets or sets the client identifier. + /// Hint: This identifier needs to be unique over all used clients / devices on the broker to avoid connection issues. + /// public string ClientId { get; set; } public string Endpoint { get; set; } diff --git a/Source/MQTTnet/Server/Status/MqttSessionStatus.cs b/Source/MQTTnet/Server/Status/MqttSessionStatus.cs index a523a37..af5a6e8 100644 --- a/Source/MQTTnet/Server/Status/MqttSessionStatus.cs +++ b/Source/MQTTnet/Server/Status/MqttSessionStatus.cs @@ -15,6 +15,10 @@ namespace MQTTnet.Server.Status _sessionsManager = sessionsManager ?? throw new ArgumentNullException(nameof(sessionsManager)); } + /// + /// Gets or sets the client identifier. + /// Hint: This identifier needs to be unique over all used clients / devices on the broker to avoid connection issues. + /// public string ClientId { get; set; } public long PendingApplicationMessagesCount { get; set; }