Interface IMqttClient
- Namespace
- Azure.Iot.Operations.Protocol
- Assembly
- Azure.Iot.Operations.Protocol.dll
An MQTT client interface that allows for connection management as well as publishing, subscribing, and unsubscribing.
public interface IMqttClient : IMqttPubSubClient, IAsyncDisposable
- Inherited Members
Properties
IsConnected
Get if this MQTT client is currently connected or not.
bool IsConnected { get; }
Property Value
Methods
ConnectAsync(MqttConnectionSettings, CancellationToken)
Connect this client to the MQTT broker configured in the provided connection settings.
Task<MqttClientConnectResult> ConnectAsync(MqttConnectionSettings settings, CancellationToken cancellationToken = default)
Parameters
settingsMqttConnectionSettingsThe details about the MQTT broker to connect to.
cancellationTokenCancellationTokenCancellation token.
Returns
- Task<MqttClientConnectResult>
The CONNACK returned by the MQTT broker.
ConnectAsync(MqttClientOptions, CancellationToken)
Connect this client to the MQTT broker configured in the provided connection options.
Task<MqttClientConnectResult> ConnectAsync(MqttClientOptions options, CancellationToken cancellationToken = default)
Parameters
optionsMqttClientOptionsThe details about the MQTT broker to connect to.
cancellationTokenCancellationTokenCancellation token.
Returns
- Task<MqttClientConnectResult>
The CONNACK returned by the MQTT broker.
DisconnectAsync(MqttClientDisconnectOptions?, CancellationToken)
Disconnect this client from the MQTT broker.
Task DisconnectAsync(MqttClientDisconnectOptions? options = null, CancellationToken cancellationToken = default)
Parameters
optionsMqttClientDisconnectOptionsThe optional parameters to include in the DISCONNECT request.
cancellationTokenCancellationTokenCancellation token.
Returns
ReconnectAsync(CancellationToken)
Reconnect the client if it is disconnected. This will use the MqttClientOptions last provided when connecting.
Task ReconnectAsync(CancellationToken cancellationToken = default)
Parameters
cancellationTokenCancellationTokenCancellation token.
Returns
SendEnhancedAuthenticationExchangeDataAsync(MqttEnhancedAuthenticationExchangeData, CancellationToken)
Send additional authentication data. May be done on an active connection.
Task SendEnhancedAuthenticationExchangeDataAsync(MqttEnhancedAuthenticationExchangeData data, CancellationToken cancellationToken = default)
Parameters
dataMqttEnhancedAuthenticationExchangeDataThe authentication data to send.
cancellationTokenCancellationTokenCancellation token.
Returns
Events
ConnectedAsync
An event that executes every time this client is connected.
event Func<MqttClientConnectedEventArgs, Task>? ConnectedAsync
Event Type
DisconnectedAsync
An event that executes every time this client is disconnected.
event Func<MqttClientDisconnectedEventArgs, Task>? DisconnectedAsync