-
Notifications
You must be signed in to change notification settings - Fork 1.1k
Upgrading guide
Volker Milbrandt edited this page Feb 3, 2021
·
30 revisions
-
MQTTnet.Adapter.MqttChannelAdapter
constructor has additional argumentIMqttPacketInspector
which is avalable as prroperty inMQTTnet.Client.Options.IMqttClientOptions
.
- Rename namespace
MQTTnet.AspNetCore
toMQTTnet.AspNetCore.Extensions
.
- Argument
logger
removed fromIMqttChannelAdapter MQTTnet.Adapter.CreateClientAdapter(IMqttClientOptions options, IMqttNetLogger logger)
. Create a constructor in your AdapterFactory and pass there the logger. - Pass the root logger to
MQTTnet.Adapter.MqttChannelAdapter
. For other use cases where you previously created anCreateChildLogger
create aCreateScopedLogger
.
- Replace
MQTTnet.Diagnostics.IMqttNetChildLogger
withMQTTnet.Diagnostics.IMqttNetLogger
. - Replace
MQTTnet.AspNetCore.ApplicationBuilderExtensions.SelectSubProtocol(requestedSubProtocolValues)
withMQTTnet.AspNetCore.MqttSubProtocolSelector.SelectSubProtocol(requestedSubProtocolValues)
. - Class
MQTTnet.AspNetCore.ApplicationBuilderExtensions
is 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.
-
MqttConnectReturnCode
is now deprecated, useMqttConnectReasonCode
instead. -
ConnectAsync
has now a CancellationToken and can be used like this:await mqttClient.ConnectAsync(options, CancellationToken.None));
-
MqttProtocolVersion
is now in theMQTTnet.Formatter
namespace. -
MqttFixedHeader
,MqttPacketBodyReader
,MqttPacketReader
,MqttPacketWriter
andMqttProtocolVersion
are now in theMQTTnet.Formatter
namespace. -
IMqttPacketSerializer
andMqttPacketSerializer
do 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.