-
Notifications
You must be signed in to change notification settings - Fork 1.1k
Upgrading guide
Volker Milbrandt edited this page Jan 21, 2021
·
30 revisions
- Nothing special at the moment.
- Breaking: Argument
loggerremoved fromIMqttChannelAdapter MQTTnet.Adapter.CreateClientAdapter(IMqttClientOptions options, IMqttNetLogger logger).
- Nothing special at the moment.
- Replace
MQTTnet.Diagnostics.IMqttNetChildLoggerwithMQTTnet.Diagnostics.IMqttNetLogger. - Replace
MQTTnet.AspNetCore.ApplicationBuilderExtensions.SelectSubProtocol(requestedSubProtocolValues)withMQTTnet.AspNetCore.MqttSubProtocolSelector.SelectSubProtocol(requestedSubProtocolValues). - Class
MQTTnet.AspNetCore.ApplicationBuilderExtensionsis deprecated and will be removed in a future version.
- Nothing special at the moment.
- There is a new
Dictionary<object, object>calledSessionItems. It allows to store custom data in the session and is available in all interceptors. For more examples, check https://github.com/chkr1011/MQTTnet/wiki/Server#storing-data-in-the-session.
-
MqttConnectReturnCodeis now deprecated, useMqttConnectReasonCodeinstead. -
ConnectAsynchas now a CancellationToken and can be used like this:await mqttClient.ConnectAsync(options, CancellationToken.None));
-
MqttProtocolVersionis now in theMQTTnet.Formatternamespace. -
MqttFixedHeader,MqttPacketBodyReader,MqttPacketReader,MqttPacketWriterandMqttProtocolVersionare now in theMQTTnet.Formatternamespace. -
IMqttPacketSerializerandMqttPacketSerializerdo not exist anymore.
- Updated async handlers:
private void Something()
{
mqttClient.ApplicationMessageReceivedHandler = new MqttApplicationMessageReceivedHandlerDelegate(OnAppMessage);
mqttClient.ConnectedHandler = new MqttClientConnectedHandlerDelegate(OnConnected);
mqttClient.DisconnectedHandler = new MqttClientDisconnectedHandlerDelegate(OnDisconnected);
mqttClient.ConnectingFailedHandler = new ConnectingFailedHandlerDelegate(OnConnectingFailed);
}
private async void OnAppMessage(MqttApplicationMessageReceivedEventArgs e)
{
}
private async void OnConnected(MqttClientConnectedEventArgs e)
{
}
private async void OnDisconnected(MqttClientDisconnectedEventArgs e)
{
}
private async void OnConnectingFailed(ManagedProcessFailedEventArgs e)
{
}- Updated async handlers:
private void Something()
{
mqttClient.ApplicationMessageReceivedHandler = new MqttApplicationMessageReceivedHandlerDelegate(OnAppMessage);
mqttClient.ConnectedHandler = new MqttClientConnectedHandlerDelegate(OnConnected);
mqttClient.DisconnectedHandler = new MqttClientDisconnectedHandlerDelegate(OnDisconnected);
}
private async void OnAppMessage(MqttApplicationMessageReceivedEventArgs e)
{
}
private async void OnConnected(MqttClientConnectedEventArgs e)
{
}
private async void OnDisconnected(MqttClientDisconnectedEventArgs e)
{
}- Checkout the issue under https://github.com/chkr1011/MQTTnet/issues/781 or open new issues if you are unsure.