mirror of
https://github.com/dotnet/MQTTnet.git
synced 2026-10-16 17:23:04 +08:00
Updated all code comments, should be ok now.
This commit is contained in:
@@ -16,95 +16,36 @@ namespace MQTTnet.Extensions.ManagedClient
|
||||
/// </summary>
|
||||
IMqttClient InternalClient { get; }
|
||||
|
||||
/// <summary>
|
||||
/// Gets a value indicating whether the client is started or not.
|
||||
/// </summary>
|
||||
bool IsStarted { get; }
|
||||
|
||||
/// <summary>
|
||||
/// Gets a value indicating whether the client is connected or not.
|
||||
/// </summary>
|
||||
bool IsConnected { get; }
|
||||
|
||||
/// <summary>
|
||||
/// Gets a pending application message count.
|
||||
/// </summary>
|
||||
int PendingApplicationMessagesCount { get; }
|
||||
|
||||
/// <summary>
|
||||
/// Gets the MQTT client options.
|
||||
/// </summary>
|
||||
IManagedMqttClientOptions Options { get; }
|
||||
|
||||
/// <summary>
|
||||
/// Gets or sets the connected handler.
|
||||
/// </summary>
|
||||
IMqttClientConnectedHandler ConnectedHandler { get; set; }
|
||||
|
||||
/// <summary>
|
||||
/// Gets or sets the disconnected handler.
|
||||
/// </summary>
|
||||
IMqttClientDisconnectedHandler DisconnectedHandler { get; set; }
|
||||
|
||||
/// <summary>
|
||||
/// Gets or sets the application message process handler.
|
||||
/// </summary>
|
||||
IApplicationMessageProcessedHandler ApplicationMessageProcessedHandler { get; set; }
|
||||
|
||||
/// <summary>
|
||||
/// Gets or sets the application message skipped handler.
|
||||
/// </summary>
|
||||
IApplicationMessageSkippedHandler ApplicationMessageSkippedHandler { get; set; }
|
||||
|
||||
/// <summary>
|
||||
/// Gets or sets the connecting failed handler.
|
||||
/// </summary>
|
||||
IConnectingFailedHandler ConnectingFailedHandler { get; set; }
|
||||
|
||||
/// <summary>
|
||||
/// Gets or sets the synchronizing subscriptions failed handler.
|
||||
/// </summary>
|
||||
ISynchronizingSubscriptionsFailedHandler SynchronizingSubscriptionsFailedHandler { get; set; }
|
||||
|
||||
/// <summary>
|
||||
/// Starts the client.
|
||||
/// </summary>
|
||||
/// <param name="options">The options.</param>
|
||||
/// <returns>A <see cref="Task"/> representing any asynchronous operation.</returns>
|
||||
Task StartAsync(IManagedMqttClientOptions options);
|
||||
|
||||
/// <summary>
|
||||
/// Stops the client.
|
||||
/// </summary>
|
||||
/// <returns>A <see cref="Task"/> representing any asynchronous operation.</returns>
|
||||
Task StopAsync();
|
||||
|
||||
/// <summary>
|
||||
/// Pings the server.
|
||||
/// </summary>
|
||||
/// <param name="cancellationToken">A token to cancel the task.</param>
|
||||
/// <returns>A <see cref="Task"/> representing any asynchronous operation.</returns>
|
||||
Task PingAsync(CancellationToken cancellationToken);
|
||||
|
||||
/// <summary>
|
||||
/// Subscribes the client.
|
||||
/// </summary>
|
||||
/// <param name="topicFilters">The topic filters.</param>
|
||||
/// <returns>A <see cref="Task"/> representing any asynchronous operation.</returns>
|
||||
Task SubscribeAsync(IEnumerable<MqttTopicFilter> topicFilters);
|
||||
|
||||
/// <summary>
|
||||
/// Unsubscribes the client.
|
||||
/// </summary>
|
||||
/// <param name="topics">The topics.</param>
|
||||
/// <returns>A <see cref="Task"/> representing any asynchronous operation.</returns>
|
||||
Task UnsubscribeAsync(IEnumerable<string> topics);
|
||||
|
||||
/// <summary>
|
||||
/// Publishes a message from the client.
|
||||
/// </summary>
|
||||
/// <param name="applicationMessages">The application messages.</param>
|
||||
/// <returns>A <see cref="Task"/> representing any asynchronous operation.</returns>
|
||||
Task PublishAsync(ManagedMqttApplicationMessage applicationMessages);
|
||||
}
|
||||
}
|
||||
@@ -7,6 +7,14 @@ namespace MQTTnet.Extensions.Rpc.Options.TopicGeneration
|
||||
{
|
||||
public string MethodName { get; set; }
|
||||
|
||||
/// <summary>
|
||||
/// 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).
|
||||
/// </summary>
|
||||
public MqttQualityOfServiceLevel QualityOfServiceLevel { get; set; }
|
||||
|
||||
public IMqttClient MqttClient { get; set; }
|
||||
|
||||
@@ -6,12 +6,6 @@ namespace MQTTnet
|
||||
{
|
||||
public interface IApplicationMessagePublisher
|
||||
{
|
||||
/// <summary>
|
||||
/// Publishes a new application message to the server.
|
||||
/// </summary>
|
||||
/// <param name="applicationMessage">The application message.</param>
|
||||
/// <param name="cancellationToken">A cancellation token to stop the task.</param>
|
||||
/// <returns>A <see cref="Task"/> representing any asynchronous operation.</returns>
|
||||
Task<MqttClientPublishResult> PublishAsync(MqttApplicationMessage applicationMessage, CancellationToken cancellationToken);
|
||||
}
|
||||
}
|
||||
|
||||
@@ -7,14 +7,8 @@ namespace MQTTnet
|
||||
{
|
||||
public interface IMqttFactory : IMqttClientFactory, IMqttServerFactory
|
||||
{
|
||||
/// <summary>
|
||||
/// Gets the default logger.
|
||||
/// </summary>
|
||||
IMqttNetLogger DefaultLogger { get; }
|
||||
|
||||
/// <summary>
|
||||
/// Gets the properties.
|
||||
/// </summary>
|
||||
IDictionary<object, object> Properties { get; }
|
||||
}
|
||||
}
|
||||
|
||||
@@ -106,33 +106,18 @@ namespace MQTTnet
|
||||
/// Hint: MQTT 5 feature only.
|
||||
private List<MqttUserProperty> _userProperties;
|
||||
|
||||
/// <summary>
|
||||
/// Adds a topic to the message.
|
||||
/// </summary>
|
||||
/// <param name="topic">The topic.</param>
|
||||
/// <returns>A new instance of the <see cref="MqttApplicationMessageBuilder"/> class.</returns>
|
||||
public MqttApplicationMessageBuilder WithTopic(string topic)
|
||||
{
|
||||
_topic = topic;
|
||||
return this;
|
||||
}
|
||||
|
||||
/// <summary>
|
||||
/// Adds a payload to the message.
|
||||
/// </summary>
|
||||
/// <param name="payload">The payload.</param>
|
||||
/// <returns>A new instance of the <see cref="MqttApplicationMessageBuilder"/> class.</returns>
|
||||
public MqttApplicationMessageBuilder WithPayload(byte[] payload)
|
||||
{
|
||||
_payload = payload;
|
||||
return this;
|
||||
}
|
||||
|
||||
/// <summary>
|
||||
/// Adds a payload to the message.
|
||||
/// </summary>
|
||||
/// <param name="payload">The payload.</param>
|
||||
/// <returns>A new instance of the <see cref="MqttApplicationMessageBuilder"/> class.</returns>
|
||||
public MqttApplicationMessageBuilder WithPayload(IEnumerable<byte> payload)
|
||||
{
|
||||
if (payload == null)
|
||||
@@ -151,11 +136,6 @@ namespace MQTTnet
|
||||
return this;
|
||||
}
|
||||
|
||||
/// <summary>
|
||||
/// Adds a payload to the message.
|
||||
/// </summary>
|
||||
/// <param name="payload">The payload.</param>
|
||||
/// <returns>A new instance of the <see cref="MqttApplicationMessageBuilder"/> class.</returns>
|
||||
public MqttApplicationMessageBuilder WithPayload(Stream payload)
|
||||
{
|
||||
if (payload == null)
|
||||
@@ -167,12 +147,6 @@ namespace MQTTnet
|
||||
return WithPayload(payload, payload.Length - payload.Position);
|
||||
}
|
||||
|
||||
/// <summary>
|
||||
/// Adds a payload to the message.
|
||||
/// </summary>
|
||||
/// <param name="payload">The payload.</param>
|
||||
/// <param name="length">The stream length.</param>
|
||||
/// <returns>A new instance of the <see cref="MqttApplicationMessageBuilder"/> class.</returns>
|
||||
public MqttApplicationMessageBuilder WithPayload(Stream payload, long length)
|
||||
{
|
||||
if (payload == null)
|
||||
@@ -194,11 +168,6 @@ namespace MQTTnet
|
||||
return this;
|
||||
}
|
||||
|
||||
/// <summary>
|
||||
/// Adds a payload to the message.
|
||||
/// </summary>
|
||||
/// <param name="payload">The payload.</param>
|
||||
/// <returns>A new instance of the <see cref="MqttApplicationMessageBuilder"/> class.</returns>
|
||||
public MqttApplicationMessageBuilder WithPayload(string payload)
|
||||
{
|
||||
if (payload == null)
|
||||
@@ -211,22 +180,12 @@ namespace MQTTnet
|
||||
return this;
|
||||
}
|
||||
|
||||
/// <summary>
|
||||
/// Adds the quality of service level to the message.
|
||||
/// </summary>
|
||||
/// <param name="qualityOfServiceLevel">The quality of service level.</param>
|
||||
/// <returns>A new instance of the <see cref="MqttApplicationMessageBuilder"/> class.</returns>
|
||||
public MqttApplicationMessageBuilder WithQualityOfServiceLevel(MqttQualityOfServiceLevel qualityOfServiceLevel)
|
||||
{
|
||||
_qualityOfServiceLevel = qualityOfServiceLevel;
|
||||
return this;
|
||||
}
|
||||
|
||||
/// <summary>
|
||||
/// Adds the quality of service level to the message.
|
||||
/// </summary>
|
||||
/// <param name="qualityOfServiceLevel">The quality of service level.</param>
|
||||
/// <returns>A new instance of the <see cref="MqttApplicationMessageBuilder"/> class.</returns>
|
||||
public MqttApplicationMessageBuilder WithQualityOfServiceLevel(int qualityOfServiceLevel)
|
||||
{
|
||||
if (qualityOfServiceLevel < 0 || qualityOfServiceLevel > 2)
|
||||
@@ -237,40 +196,24 @@ namespace MQTTnet
|
||||
return WithQualityOfServiceLevel((MqttQualityOfServiceLevel)qualityOfServiceLevel);
|
||||
}
|
||||
|
||||
/// <summary>
|
||||
/// Adds retain flag to the message.
|
||||
/// </summary>
|
||||
/// <returns>A new instance of the <see cref="MqttApplicationMessageBuilder"/> class.</returns>
|
||||
public MqttApplicationMessageBuilder WithRetainFlag(bool value = true)
|
||||
{
|
||||
_retain = value;
|
||||
return this;
|
||||
}
|
||||
|
||||
/// <summary>
|
||||
/// Adds the quality of service level 0 (at least once) to the message.
|
||||
/// </summary>
|
||||
/// <returns>A new instance of the <see cref="MqttApplicationMessageBuilder"/> class.</returns>
|
||||
public MqttApplicationMessageBuilder WithAtLeastOnceQoS()
|
||||
{
|
||||
_qualityOfServiceLevel = MqttQualityOfServiceLevel.AtLeastOnce;
|
||||
return this;
|
||||
}
|
||||
|
||||
/// <summary>
|
||||
/// Adds the quality of service level 1 (at most once) to the message.
|
||||
/// </summary>
|
||||
/// <returns>A new instance of the <see cref="MqttApplicationMessageBuilder"/> class.</returns>
|
||||
public MqttApplicationMessageBuilder WithAtMostOnceQoS()
|
||||
{
|
||||
_qualityOfServiceLevel = MqttQualityOfServiceLevel.AtMostOnce;
|
||||
return this;
|
||||
}
|
||||
|
||||
/// <summary>
|
||||
/// Adds the quality of service level 2 (exactly once) to the message.
|
||||
/// </summary>
|
||||
/// <returns>A new instance of the <see cref="MqttApplicationMessageBuilder"/> class.</returns>
|
||||
public MqttApplicationMessageBuilder WithExactlyOnceQoS()
|
||||
{
|
||||
_qualityOfServiceLevel = MqttQualityOfServiceLevel.ExactlyOnce;
|
||||
@@ -383,10 +326,6 @@ namespace MQTTnet
|
||||
return this;
|
||||
}
|
||||
|
||||
/// <summary>
|
||||
/// Builds the message.
|
||||
/// </summary>
|
||||
/// <returns>A new instance of the <see cref="MqttApplicationMessage"/> class.</returns>
|
||||
public MqttApplicationMessage Build()
|
||||
{
|
||||
if (!_topicAlias.HasValue && string.IsNullOrEmpty(_topic))
|
||||
|
||||
@@ -5,11 +5,6 @@ namespace MQTTnet
|
||||
{
|
||||
public static class MqttApplicationMessageExtensions
|
||||
{
|
||||
/// <summary>
|
||||
/// Converts the payload to a string if possible.
|
||||
/// </summary>
|
||||
/// <param name="applicationMessage">The application message.</param>
|
||||
/// <returns>A string.</returns>
|
||||
public static string ConvertPayloadToString(this MqttApplicationMessage applicationMessage)
|
||||
{
|
||||
if (applicationMessage == null) throw new ArgumentNullException(nameof(applicationMessage));
|
||||
|
||||
@@ -10,6 +10,10 @@ namespace MQTTnet
|
||||
ApplicationMessage = applicationMessage ?? throw new ArgumentNullException(nameof(applicationMessage));
|
||||
}
|
||||
|
||||
/// <summary>
|
||||
/// Gets the client identifier.
|
||||
/// Hint: This identifier needs to be unique over all used clients / devices on the broker to avoid connection issues.
|
||||
/// </summary>
|
||||
public string ClientId { get; }
|
||||
|
||||
public MqttApplicationMessage ApplicationMessage { get; }
|
||||
|
||||
@@ -28,62 +28,36 @@ namespace MQTTnet
|
||||
/// </summary>
|
||||
string _topic;
|
||||
|
||||
/// <summary>
|
||||
/// Adds a topic to the topic filter.
|
||||
/// </summary>
|
||||
/// <param name="topic">The topic.</param>
|
||||
/// <returns>A new instance of the <see cref="MqttTopicFilterBuilder"/> class.</returns>
|
||||
public MqttTopicFilterBuilder WithTopic(string topic)
|
||||
{
|
||||
_topic = topic;
|
||||
return this;
|
||||
}
|
||||
|
||||
/// <summary>
|
||||
/// Adds the quality of service level to the topic filter.
|
||||
/// </summary>
|
||||
/// <param name="qualityOfServiceLevel">The quality of service level.</param>
|
||||
/// <returns>A new instance of the <see cref="MqttTopicFilterBuilder"/> class.</returns>
|
||||
public MqttTopicFilterBuilder WithQualityOfServiceLevel(MqttQualityOfServiceLevel qualityOfServiceLevel)
|
||||
{
|
||||
_qualityOfServiceLevel = qualityOfServiceLevel;
|
||||
return this;
|
||||
}
|
||||
|
||||
/// <summary>
|
||||
/// Adds the quality of service level 0 (at least once) to the topic filter.
|
||||
/// </summary>
|
||||
/// <returns>A new instance of the <see cref="MqttTopicFilterBuilder"/> class.</returns>
|
||||
public MqttTopicFilterBuilder WithAtLeastOnceQoS()
|
||||
{
|
||||
_qualityOfServiceLevel = MqttQualityOfServiceLevel.AtLeastOnce;
|
||||
return this;
|
||||
}
|
||||
|
||||
/// <summary>
|
||||
/// Adds the quality of service level 1 (at most once) to the topic filter.
|
||||
/// </summary>
|
||||
/// <returns>A new instance of the <see cref="MqttTopicFilterBuilder"/> class.</returns>
|
||||
public MqttTopicFilterBuilder WithAtMostOnceQoS()
|
||||
{
|
||||
_qualityOfServiceLevel = MqttQualityOfServiceLevel.AtMostOnce;
|
||||
return this;
|
||||
}
|
||||
|
||||
/// <summary>
|
||||
/// Adds the quality of service level 2 (exactly once) to the topic filter.
|
||||
/// </summary>
|
||||
/// <returns>A new instance of the <see cref="MqttTopicFilterBuilder"/> class.</returns>
|
||||
public MqttTopicFilterBuilder WithExactlyOnceQoS()
|
||||
{
|
||||
_qualityOfServiceLevel = MqttQualityOfServiceLevel.ExactlyOnce;
|
||||
return this;
|
||||
}
|
||||
|
||||
/// <summary>
|
||||
/// Builds the topic filter.
|
||||
/// </summary>
|
||||
/// <returns>A new instance of the <see cref="MqttTopicFilter"/> class.</returns>
|
||||
public MqttTopicFilter Build()
|
||||
{
|
||||
if (string.IsNullOrEmpty(_topic))
|
||||
|
||||
@@ -8,6 +8,14 @@ namespace MQTTnet.Server
|
||||
|
||||
public bool IsSubscribed { get; set; }
|
||||
|
||||
/// <summary>
|
||||
/// 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).
|
||||
/// </summary>
|
||||
public MqttQualityOfServiceLevel QualityOfServiceLevel { get; set; }
|
||||
}
|
||||
}
|
||||
|
||||
@@ -4,6 +4,10 @@ namespace MQTTnet.Server
|
||||
{
|
||||
public interface IMqttClientSession
|
||||
{
|
||||
/// <summary>
|
||||
/// Gets the client identifier.
|
||||
/// Hint: This identifier needs to be unique over all used clients / devices on the broker to avoid connection issues.
|
||||
/// </summary>
|
||||
string ClientId { get; }
|
||||
|
||||
Task StopAsync();
|
||||
|
||||
@@ -7,37 +7,14 @@ namespace MQTTnet.Server
|
||||
{
|
||||
public interface IMqttServerFactory
|
||||
{
|
||||
/// <summary>
|
||||
/// Gets the default server adapters.
|
||||
/// </summary>
|
||||
IList<Func<IMqttFactory, IMqttServerAdapter>> DefaultServerAdapters { get; }
|
||||
|
||||
/// <summary>
|
||||
/// Creates a new default MQTT server.
|
||||
/// </summary>
|
||||
/// <returns>A new <see cref="IMqttServer"/>.</returns>
|
||||
IMqttServer CreateMqttServer();
|
||||
|
||||
/// <summary>
|
||||
/// Creates a new default MQTT server.
|
||||
/// </summary>
|
||||
/// <param name="logger">The logger.</param>
|
||||
/// <returns>A new <see cref="IMqttServer"/>.</returns>
|
||||
IMqttServer CreateMqttServer(IMqttNetLogger logger);
|
||||
|
||||
/// <summary>
|
||||
/// Creates a new default MQTT server.
|
||||
/// </summary>
|
||||
/// <param name="adapters">The adapters.</param>
|
||||
/// <returns>A new <see cref="IMqttServer"/>.</returns>
|
||||
IMqttServer CreateMqttServer(IEnumerable<IMqttServerAdapter> adapters);
|
||||
|
||||
/// <summary>
|
||||
/// Creates a new default MQTT server.
|
||||
/// </summary>
|
||||
/// <param name="adapters">The adapters.</param>
|
||||
/// <param name="logger">The logger.</param>
|
||||
/// <returns>A new <see cref="IMqttServer"/>.</returns>
|
||||
IMqttServer CreateMqttServer(IEnumerable<IMqttServerAdapter> adapters, IMqttNetLogger logger);
|
||||
}
|
||||
}
|
||||
@@ -4,6 +4,10 @@ namespace MQTTnet.Server
|
||||
{
|
||||
public interface IMqttServerOptions
|
||||
{
|
||||
/// <summary>
|
||||
/// Gets the client identifier.
|
||||
/// Hint: This identifier needs to be unique over all used clients / devices on the broker to avoid connection issues.
|
||||
/// </summary>
|
||||
string ClientId { get; set; }
|
||||
|
||||
bool EnablePersistentSessions { get; }
|
||||
|
||||
@@ -5,14 +5,26 @@ namespace MQTTnet.Server
|
||||
{
|
||||
public interface IMqttServerPersistedSession
|
||||
{
|
||||
/// <summary>
|
||||
/// Gets the client identifier.
|
||||
/// Hint: This identifier needs to be unique over all used clients / devices on the broker to avoid connection issues.
|
||||
/// </summary>
|
||||
string ClientId { get; }
|
||||
|
||||
IDictionary<object, object> Items { get; }
|
||||
|
||||
IList<MqttTopicFilter> Subscriptions { get; }
|
||||
|
||||
/// <summary>
|
||||
/// Gets the last will message.
|
||||
/// In MQTT, you use the last will message feature to notify other clients about an ungracefully disconnected client.
|
||||
/// </summary>
|
||||
MqttApplicationMessage WillMessage { get; }
|
||||
|
||||
/// <summary>
|
||||
/// Gets the will delay interval.
|
||||
/// This is the time between the client disconnect and the time the will message will be sent.
|
||||
/// </summary>
|
||||
uint? WillDelayInterval { get; }
|
||||
|
||||
DateTime? SessionExpiryTimestamp { get; }
|
||||
|
||||
@@ -18,6 +18,10 @@ namespace MQTTnet.Server
|
||||
/// </summary>
|
||||
public IMqttNetScopedLogger Logger { get; }
|
||||
|
||||
/// <summary>
|
||||
/// Gets the client identifier.
|
||||
/// Hint: This identifier needs to be unique over all used clients / devices on the broker to avoid connection issues.
|
||||
/// </summary>
|
||||
public string ClientId { get; }
|
||||
|
||||
public MqttApplicationMessage ApplicationMessage { get; set; }
|
||||
|
||||
@@ -20,6 +20,14 @@ namespace MQTTnet.Server
|
||||
|
||||
public bool AcceptEnqueue { get; set; } = true;
|
||||
|
||||
/// <summary>
|
||||
/// 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).
|
||||
/// </summary>
|
||||
public MqttQualityOfServiceLevel SubscriptionQualityOfServiceLevel { get; set; }
|
||||
}
|
||||
}
|
||||
|
||||
@@ -21,6 +21,10 @@ namespace MQTTnet.Server
|
||||
SessionItems = sessionItems;
|
||||
}
|
||||
|
||||
/// <summary>
|
||||
/// Gets the client identifier.
|
||||
/// Hint: This identifier needs to be unique over all used clients / devices on the broker to avoid connection issues.
|
||||
/// </summary>
|
||||
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]);
|
||||
|
||||
/// <summary>
|
||||
/// Gets or sets the will delay interval.
|
||||
/// This is the time between the client disconnect and the time the will message will be sent.
|
||||
/// </summary>
|
||||
public MqttApplicationMessage WillMessage => _connectPacket?.WillMessage;
|
||||
|
||||
/// <summary>
|
||||
/// 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.
|
||||
/// </summary>
|
||||
public bool? CleanSession => _connectPacket?.CleanSession;
|
||||
|
||||
/// <summary>
|
||||
/// 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.
|
||||
/// </summary>
|
||||
public ushort? KeepAlivePeriod => _connectPacket?.KeepAlivePeriod;
|
||||
|
||||
/// <summary>
|
||||
/// 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.
|
||||
/// </summary>
|
||||
public List<MqttUserProperty> UserProperties => _connectPacket?.Properties?.UserProperties;
|
||||
|
||||
/// <summary>
|
||||
/// Gets or sets the authentication data.
|
||||
/// Hint: MQTT 5 feature only.
|
||||
/// </summary>
|
||||
public byte[] AuthenticationData => _connectPacket?.Properties?.AuthenticationData;
|
||||
|
||||
/// <summary>
|
||||
/// Gets or sets the authentication method.
|
||||
/// Hint: MQTT 5 feature only.
|
||||
/// </summary>
|
||||
public string AuthenticationMethod => _connectPacket?.Properties?.AuthenticationMethod;
|
||||
|
||||
public uint? MaximumPacketSize => _connectPacket?.Properties?.MaximumPacketSize;
|
||||
|
||||
/// <summary>
|
||||
/// Gets or sets the receive maximum.
|
||||
/// This gives the maximum length of the receive messages.
|
||||
/// </summary>
|
||||
public ushort? ReceiveMaximum => _connectPacket?.Properties?.ReceiveMaximum;
|
||||
|
||||
/// <summary>
|
||||
/// Gets or sets the topic alias maximum.
|
||||
/// This gives the maximum length of the topic alias.
|
||||
/// </summary>
|
||||
public ushort? TopicAliasMaximum => _connectPacket?.Properties?.TopicAliasMaximum;
|
||||
|
||||
/// <summary>
|
||||
/// Gets the request problem information.
|
||||
/// Hint: MQTT 5 feature only.
|
||||
/// </summary>
|
||||
public bool? RequestProblemInformation => _connectPacket?.Properties?.RequestProblemInformation;
|
||||
|
||||
/// <summary>
|
||||
/// Gets the request response information.
|
||||
/// Hint: MQTT 5 feature only.
|
||||
/// </summary>
|
||||
public bool? RequestResponseInformation => _connectPacket?.Properties?.RequestResponseInformation;
|
||||
|
||||
/// <summary>
|
||||
/// Gets the session expiry interval.
|
||||
/// The time after a session expires when it's not actively used.
|
||||
/// </summary>
|
||||
public uint? SessionExpiryInterval => _connectPacket?.Properties?.SessionExpiryInterval;
|
||||
|
||||
/// <summary>
|
||||
/// Gets or sets the will delay interval.
|
||||
/// This is the time between the client disconnect and the time the will message will be sent.
|
||||
/// </summary>
|
||||
public uint? WillDelayInterval => _connectPacket?.Properties?.WillDelayInterval;
|
||||
|
||||
/// <summary>
|
||||
@@ -79,14 +141,26 @@ namespace MQTTnet.Server
|
||||
}
|
||||
|
||||
/// <summary>
|
||||
/// 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.
|
||||
/// </summary>
|
||||
public MqttConnectReasonCode ReasonCode { get; set; } = MqttConnectReasonCode.Success;
|
||||
|
||||
/// <summary>
|
||||
/// 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.
|
||||
/// </summary>
|
||||
public List<MqttUserProperty> ResponseUserProperties { get; set; }
|
||||
|
||||
/// <summary>
|
||||
/// Gets or sets the response authentication data.
|
||||
/// Hint: MQTT 5 feature only.
|
||||
/// </summary>
|
||||
public byte[] ResponseAuthenticationData { get; set; }
|
||||
|
||||
public string AssignedClientIdentifier { get; set; }
|
||||
|
||||
@@ -11,6 +11,14 @@ namespace MQTTnet.Server
|
||||
|
||||
public bool IsRetainedMessage { get; set; }
|
||||
|
||||
/// <summary>
|
||||
/// 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).
|
||||
/// </summary>
|
||||
public MqttQualityOfServiceLevel SubscriptionQualityOfServiceLevel { get; set; }
|
||||
|
||||
[Obsolete("Use 'SubscriptionQualityOfServiceLevel' instead.")]
|
||||
|
||||
@@ -9,6 +9,10 @@ namespace MQTTnet.Server
|
||||
ClientId = clientId ?? throw new ArgumentNullException(nameof(clientId));
|
||||
}
|
||||
|
||||
/// <summary>
|
||||
/// Gets the client identifier.
|
||||
/// Hint: This identifier needs to be unique over all used clients / devices on the broker to avoid connection issues.
|
||||
/// </summary>
|
||||
public string ClientId { get; }
|
||||
}
|
||||
}
|
||||
|
||||
@@ -9,7 +9,11 @@ namespace MQTTnet.Server
|
||||
ClientId = clientId ?? throw new ArgumentNullException(nameof(clientId));
|
||||
DisconnectType = disconnectType;
|
||||
}
|
||||
|
||||
|
||||
/// <summary>
|
||||
/// Gets the client identifier.
|
||||
/// Hint: This identifier needs to be unique over all used clients / devices on the broker to avoid connection issues.
|
||||
/// </summary>
|
||||
public string ClientId { get; }
|
||||
|
||||
public MqttClientDisconnectType DisconnectType { get; }
|
||||
|
||||
@@ -10,8 +10,16 @@ namespace MQTTnet.Server
|
||||
TopicFilter = topicFilter ?? throw new ArgumentNullException(nameof(topicFilter));
|
||||
}
|
||||
|
||||
/// <summary>
|
||||
/// Gets the client identifier.
|
||||
/// Hint: This identifier needs to be unique over all used clients / devices on the broker to avoid connection issues.
|
||||
/// </summary>
|
||||
public string ClientId { get; }
|
||||
|
||||
/// <summary>
|
||||
/// Gets the topic filter.
|
||||
/// The topic filter can contain topics and wildcards.
|
||||
/// </summary>
|
||||
public MqttTopicFilter TopicFilter { get; }
|
||||
}
|
||||
}
|
||||
|
||||
@@ -10,8 +10,16 @@ namespace MQTTnet.Server
|
||||
TopicFilter = topicFilter ?? throw new ArgumentNullException(nameof(topicFilter));
|
||||
}
|
||||
|
||||
/// <summary>
|
||||
/// Gets the client identifier.
|
||||
/// Hint: This identifier needs to be unique over all used clients / devices on the broker to avoid connection issues.
|
||||
/// </summary>
|
||||
public string ClientId { get; }
|
||||
|
||||
/// <summary>
|
||||
/// Gets or sets the topic filter.
|
||||
/// The topic filter can contain topics and wildcards.
|
||||
/// </summary>
|
||||
public string TopicFilter { get; }
|
||||
}
|
||||
}
|
||||
|
||||
@@ -8,6 +8,10 @@ namespace MQTTnet.Server
|
||||
|
||||
public MqttServerTlsTcpEndpointOptions TlsEndpointOptions { get; } = new MqttServerTlsTcpEndpointOptions();
|
||||
|
||||
/// <summary>
|
||||
/// 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.
|
||||
/// </summary>
|
||||
public string ClientId { get; set; }
|
||||
|
||||
public bool EnablePersistentSessions { get; set; }
|
||||
|
||||
@@ -11,8 +11,16 @@ namespace MQTTnet.Server
|
||||
SessionItems = sessionItems;
|
||||
}
|
||||
|
||||
/// <summary>
|
||||
/// Gets the client identifier.
|
||||
/// Hint: This identifier needs to be unique over all used clients / devices on the broker to avoid connection issues.
|
||||
/// </summary>
|
||||
public string ClientId { get; }
|
||||
|
||||
/// <summary>
|
||||
/// Gets or sets the topic filter.
|
||||
/// The topic filter can contain topics and wildcards.
|
||||
/// </summary>
|
||||
public MqttTopicFilter TopicFilter { get; set; }
|
||||
|
||||
/// <summary>
|
||||
|
||||
@@ -11,8 +11,17 @@ namespace MQTTnet.Server
|
||||
SessionItems = sessionItems;
|
||||
}
|
||||
|
||||
/// <summary>
|
||||
/// Gets the client identifier.
|
||||
/// Hint: This identifier needs to be unique over all used clients / devices on the broker to avoid connection issues.
|
||||
/// </summary>
|
||||
public string ClientId { get; }
|
||||
|
||||
/// <summary>
|
||||
/// 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).
|
||||
/// </summary>
|
||||
public string Topic { get; set; }
|
||||
|
||||
/// <summary>
|
||||
|
||||
@@ -6,6 +6,10 @@ namespace MQTTnet.Server.Status
|
||||
{
|
||||
public interface IMqttClientStatus
|
||||
{
|
||||
/// <summary>
|
||||
/// Gets the client identifier.
|
||||
/// Hint: This identifier needs to be unique over all used clients / devices on the broker to avoid connection issues.
|
||||
/// </summary>
|
||||
string ClientId { get; }
|
||||
|
||||
string Endpoint { get; }
|
||||
|
||||
@@ -5,6 +5,10 @@ namespace MQTTnet.Server.Status
|
||||
{
|
||||
public interface IMqttSessionStatus
|
||||
{
|
||||
/// <summary>
|
||||
/// Gets the client identifier.
|
||||
/// Hint: This identifier needs to be unique over all used clients / devices on the broker to avoid connection issues.
|
||||
/// </summary>
|
||||
string ClientId { get; }
|
||||
|
||||
long PendingApplicationMessagesCount { get; }
|
||||
|
||||
@@ -14,6 +14,10 @@ namespace MQTTnet.Server.Status
|
||||
_connection = connection ?? throw new ArgumentNullException(nameof(connection));
|
||||
}
|
||||
|
||||
/// <summary>
|
||||
/// 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.
|
||||
/// </summary>
|
||||
public string ClientId { get; set; }
|
||||
|
||||
public string Endpoint { get; set; }
|
||||
|
||||
@@ -15,6 +15,10 @@ namespace MQTTnet.Server.Status
|
||||
_sessionsManager = sessionsManager ?? throw new ArgumentNullException(nameof(sessionsManager));
|
||||
}
|
||||
|
||||
/// <summary>
|
||||
/// 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.
|
||||
/// </summary>
|
||||
public string ClientId { get; set; }
|
||||
|
||||
public long PendingApplicationMessagesCount { get; set; }
|
||||
|
||||
Reference in New Issue
Block a user