Bläddra i källkod

Disconnected Endpoint

release/3.x.x
Wang Chunlong 3 år sedan
förälder
incheckning
cf8ea872d3
3 ändrade filer med 12 tillägg och 7 borttagningar
  1. +4
    -2
      Source/MQTTnet/Server/MqttClientSessionsManager.cs
  2. +5
    -2
      Source/MQTTnet/Server/MqttServerClientDisconnectedEventArgs.cs
  3. +3
    -3
      Source/MQTTnet/Server/MqttServerEventDispatcher.cs

+ 4
- 2
Source/MQTTnet/Server/MqttClientSessionsManager.cs Visa fil

@@ -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 clientEndpoint = channelAdapter.Endpoint;

await SafeCleanupChannelAsync(channelAdapter).ConfigureAwait(false);

if (clientId != null)
{
await _eventDispatcher.SafeNotifyClientDisconnectedAsync(clientId, disconnectType).ConfigureAwait(false);
await _eventDispatcher.SafeNotifyClientDisconnectedAsync(clientId, disconnectType, clientEndpoint).ConfigureAwait(false);
}
}



+ 5
- 2
Source/MQTTnet/Server/MqttServerClientDisconnectedEventArgs.cs Visa fil

@@ -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;
}

/// <summary>
@@ -17,5 +18,7 @@ namespace MQTTnet.Server
public string ClientId { get; }

public MqttClientDisconnectType DisconnectType { get; }

public string Endpoint { get; set; }
}
}

+ 3
- 3
Source/MQTTnet/Server/MqttServerEventDispatcher.cs Visa fil

@@ -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 clientEndpoint)
{
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, clientEndpoint)).ConfigureAwait(false);
}
catch (Exception exception)
{


Laddar…
Avbryt
Spara