diff --git a/Source/MQTTnet/Server/MqttClientSessionsManager.cs b/Source/MQTTnet/Server/MqttClientSessionsManager.cs index 2c3202b..f0c6955 100644 --- a/Source/MQTTnet/Server/MqttClientSessionsManager.cs +++ b/Source/MQTTnet/Server/MqttClientSessionsManager.cs @@ -1,4 +1,4 @@ -using MQTTnet.Adapter; +using MQTTnet.Adapter; using MQTTnet.Diagnostics; using MQTTnet.Exceptions; using MQTTnet.Formatter; @@ -237,11 +237,13 @@ namespace MQTTnet.Server } } + var endpoint = channelAdapter.Endpoint; + await SafeCleanupChannelAsync(channelAdapter).ConfigureAwait(false); if (clientId != null) { - await _eventDispatcher.SafeNotifyClientDisconnectedAsync(clientId, disconnectType).ConfigureAwait(false); + await _eventDispatcher.SafeNotifyClientDisconnectedAsync(clientId, disconnectType, endpoint).ConfigureAwait(false); } } diff --git a/Source/MQTTnet/Server/MqttServerClientDisconnectedEventArgs.cs b/Source/MQTTnet/Server/MqttServerClientDisconnectedEventArgs.cs index d2e7fe5..9834b20 100644 --- a/Source/MQTTnet/Server/MqttServerClientDisconnectedEventArgs.cs +++ b/Source/MQTTnet/Server/MqttServerClientDisconnectedEventArgs.cs @@ -1,13 +1,14 @@ -using System; +using System; namespace MQTTnet.Server { public class MqttServerClientDisconnectedEventArgs : EventArgs { - public MqttServerClientDisconnectedEventArgs(string clientId, MqttClientDisconnectType disconnectType) + public MqttServerClientDisconnectedEventArgs(string clientId, MqttClientDisconnectType disconnectType, string endpoint) { ClientId = clientId ?? throw new ArgumentNullException(nameof(clientId)); DisconnectType = disconnectType; + Endpoint = endpoint; } /// @@ -17,5 +18,7 @@ namespace MQTTnet.Server public string ClientId { get; } public MqttClientDisconnectType DisconnectType { get; } + + public string Endpoint { get; } } } diff --git a/Source/MQTTnet/Server/MqttServerEventDispatcher.cs b/Source/MQTTnet/Server/MqttServerEventDispatcher.cs index 51f35a4..0c2d1b0 100644 --- a/Source/MQTTnet/Server/MqttServerEventDispatcher.cs +++ b/Source/MQTTnet/Server/MqttServerEventDispatcher.cs @@ -1,4 +1,4 @@ -using MQTTnet.Client.Receiving; +using MQTTnet.Client.Receiving; using MQTTnet.Diagnostics; using System; using System.Threading.Tasks; @@ -44,7 +44,7 @@ namespace MQTTnet.Server } } - public async Task SafeNotifyClientDisconnectedAsync(string clientId, MqttClientDisconnectType disconnectType) + public async Task SafeNotifyClientDisconnectedAsync(string clientId, MqttClientDisconnectType disconnectType, string endpoint) { try { @@ -54,7 +54,7 @@ namespace MQTTnet.Server return; } - await handler.HandleClientDisconnectedAsync(new MqttServerClientDisconnectedEventArgs(clientId, disconnectType)).ConfigureAwait(false); + await handler.HandleClientDisconnectedAsync(new MqttServerClientDisconnectedEventArgs(clientId, disconnectType, endpoint)).ConfigureAwait(false); } catch (Exception exception) {