Table of Contents

Class MqttServer

Namespace
MQTTnet.Server
Assembly
MQTTnet.dll
public class MqttServer : Disposable, IDisposable
Inheritance
MqttServer
Implements
Inherited Members
Extension Methods

Constructors

MqttServer(MqttServerOptions, IEnumerable<IMqttServerAdapter>, IMqttNetLogger)

public MqttServer(MqttServerOptions options, IEnumerable<IMqttServerAdapter> adapters, IMqttNetLogger logger)

Parameters

options MqttServerOptions
adapters IEnumerable<IMqttServerAdapter>
logger IMqttNetLogger

Properties

AcceptNewConnections

Gets or sets whether the server will accept new connections. If not, the server will close the connection without any notification (DISCONNECT packet). This feature can be used when the server is shutting down.

public bool AcceptNewConnections { get; set; }

Property Value

bool

IsStarted

public bool IsStarted { get; }

Property Value

bool

ServerSessionItems

Gives access to the session items which belong to this server. This session items are passed to several events instead of the client session items if the event is caused by the server instead of a client.

public IDictionary ServerSessionItems { get; }

Property Value

IDictionary

Methods

DeleteRetainedMessagesAsync()

public Task DeleteRetainedMessagesAsync()

Returns

Task

DisconnectClientAsync(string, MqttServerClientDisconnectOptions)

public Task DisconnectClientAsync(string id, MqttServerClientDisconnectOptions options)

Parameters

id string
options MqttServerClientDisconnectOptions

Returns

Task

Dispose(bool)

protected override void Dispose(bool disposing)

Parameters

disposing bool

GetClientsAsync()

public Task<IList<MqttClientStatus>> GetClientsAsync()

Returns

Task<IList<MqttClientStatus>>

GetRetainedMessageAsync(string)

public Task<MqttApplicationMessage> GetRetainedMessageAsync(string topic)

Parameters

topic string

Returns

Task<MqttApplicationMessage>

GetRetainedMessagesAsync()

public Task<IList<MqttApplicationMessage>> GetRetainedMessagesAsync()

Returns

Task<IList<MqttApplicationMessage>>

GetSessionsAsync()

public Task<IList<MqttSessionStatus>> GetSessionsAsync()

Returns

Task<IList<MqttSessionStatus>>

InjectApplicationMessage(InjectedMqttApplicationMessage, CancellationToken)

public Task InjectApplicationMessage(InjectedMqttApplicationMessage injectedApplicationMessage, CancellationToken cancellationToken = default)

Parameters

injectedApplicationMessage InjectedMqttApplicationMessage
cancellationToken CancellationToken

Returns

Task

StartAsync()

public Task StartAsync()

Returns

Task

StopAsync(MqttServerStopOptions)

public Task StopAsync(MqttServerStopOptions options)

Parameters

options MqttServerStopOptions

Returns

Task

SubscribeAsync(string, ICollection<MqttTopicFilter>)

public Task SubscribeAsync(string clientId, ICollection<MqttTopicFilter> topicFilters)

Parameters

clientId string
topicFilters ICollection<MqttTopicFilter>

Returns

Task

UnsubscribeAsync(string, ICollection<string>)

public Task UnsubscribeAsync(string clientId, ICollection<string> topicFilters)

Parameters

clientId string
topicFilters ICollection<string>

Returns

Task

UpdateRetainedMessageAsync(MqttApplicationMessage)

public Task UpdateRetainedMessageAsync(MqttApplicationMessage retainedMessage)

Parameters

retainedMessage MqttApplicationMessage

Returns

Task

Events

ApplicationMessageEnqueuedOrDroppedAsync

public event Func<ApplicationMessageEnqueuedEventArgs, Task> ApplicationMessageEnqueuedOrDroppedAsync

Event Type

Func<ApplicationMessageEnqueuedEventArgs, Task>

ApplicationMessageNotConsumedAsync

public event Func<ApplicationMessageNotConsumedEventArgs, Task> ApplicationMessageNotConsumedAsync

Event Type

Func<ApplicationMessageNotConsumedEventArgs, Task>

ClientAcknowledgedPublishPacketAsync

public event Func<ClientAcknowledgedPublishPacketEventArgs, Task> ClientAcknowledgedPublishPacketAsync

Event Type

Func<ClientAcknowledgedPublishPacketEventArgs, Task>

ClientConnectedAsync

public event Func<ClientConnectedEventArgs, Task> ClientConnectedAsync

Event Type

Func<ClientConnectedEventArgs, Task>

ClientDisconnectedAsync

public event Func<ClientDisconnectedEventArgs, Task> ClientDisconnectedAsync

Event Type

Func<ClientDisconnectedEventArgs, Task>

ClientSubscribedTopicAsync

public event Func<ClientSubscribedTopicEventArgs, Task> ClientSubscribedTopicAsync

Event Type

Func<ClientSubscribedTopicEventArgs, Task>

ClientUnsubscribedTopicAsync

public event Func<ClientUnsubscribedTopicEventArgs, Task> ClientUnsubscribedTopicAsync

Event Type

Func<ClientUnsubscribedTopicEventArgs, Task>

InterceptingClientEnqueueAsync

public event Func<InterceptingClientApplicationMessageEnqueueEventArgs, Task> InterceptingClientEnqueueAsync

Event Type

Func<InterceptingClientApplicationMessageEnqueueEventArgs, Task>

InterceptingInboundPacketAsync

public event Func<InterceptingPacketEventArgs, Task> InterceptingInboundPacketAsync

Event Type

Func<InterceptingPacketEventArgs, Task>

InterceptingOutboundPacketAsync

public event Func<InterceptingPacketEventArgs, Task> InterceptingOutboundPacketAsync

Event Type

Func<InterceptingPacketEventArgs, Task>

InterceptingPublishAsync

public event Func<InterceptingPublishEventArgs, Task> InterceptingPublishAsync

Event Type

Func<InterceptingPublishEventArgs, Task>

InterceptingSubscriptionAsync

public event Func<InterceptingSubscriptionEventArgs, Task> InterceptingSubscriptionAsync

Event Type

Func<InterceptingSubscriptionEventArgs, Task>

InterceptingUnsubscriptionAsync

public event Func<InterceptingUnsubscriptionEventArgs, Task> InterceptingUnsubscriptionAsync

Event Type

Func<InterceptingUnsubscriptionEventArgs, Task>

LoadingRetainedMessageAsync

public event Func<LoadingRetainedMessagesEventArgs, Task> LoadingRetainedMessageAsync

Event Type

Func<LoadingRetainedMessagesEventArgs, Task>

PreparingSessionAsync

public event Func<EventArgs, Task> PreparingSessionAsync

Event Type

Func<EventArgs, Task>

QueuedApplicationMessageOverwrittenAsync

public event Func<QueueMessageOverwrittenEventArgs, Task> QueuedApplicationMessageOverwrittenAsync

Event Type

Func<QueueMessageOverwrittenEventArgs, Task>

RetainedMessageChangedAsync

public event Func<RetainedMessageChangedEventArgs, Task> RetainedMessageChangedAsync

Event Type

Func<RetainedMessageChangedEventArgs, Task>

RetainedMessagesClearedAsync

public event Func<EventArgs, Task> RetainedMessagesClearedAsync

Event Type

Func<EventArgs, Task>

SessionDeletedAsync

public event Func<SessionDeletedEventArgs, Task> SessionDeletedAsync

Event Type

Func<SessionDeletedEventArgs, Task>

StartedAsync

public event Func<EventArgs, Task> StartedAsync

Event Type

Func<EventArgs, Task>

StoppedAsync

public event Func<EventArgs, Task> StoppedAsync

Event Type

Func<EventArgs, Task>

ValidatingConnectionAsync

public event Func<ValidatingConnectionEventArgs, Task> ValidatingConnectionAsync

Event Type

Func<ValidatingConnectionEventArgs, Task>