mirror of
https://github.com/dotnet/MQTTnet.git
synced 2026-10-15 00:15:15 +08:00
1742 some bug in mqttclientconnectionvalidatorhandle (#1746)
This commit is contained in:
@@ -58,7 +58,7 @@ namespace MQTTnet.Server
|
||||
_eventContainer = eventContainer ?? throw new ArgumentNullException(nameof(eventContainer));
|
||||
}
|
||||
|
||||
public async Task CloseAllConnectionsAsync()
|
||||
public async Task CloseAllConnections()
|
||||
{
|
||||
List<MqttClient> connections;
|
||||
lock (_clients)
|
||||
@@ -306,17 +306,17 @@ namespace MQTTnet.Server
|
||||
}
|
||||
}
|
||||
|
||||
public Task<IList<MqttClientStatus>> GetClientStatusesAsync()
|
||||
public Task<IList<MqttClientStatus>> GetClientsStatus()
|
||||
{
|
||||
var result = new List<MqttClientStatus>();
|
||||
|
||||
lock (_clients)
|
||||
{
|
||||
foreach (var connection in _clients.Values)
|
||||
foreach (var client in _clients.Values)
|
||||
{
|
||||
var clientStatus = new MqttClientStatus(connection)
|
||||
var clientStatus = new MqttClientStatus(client)
|
||||
{
|
||||
Session = new MqttSessionStatus(connection.Session)
|
||||
Session = new MqttSessionStatus(client.Session)
|
||||
};
|
||||
|
||||
result.Add(clientStatus);
|
||||
@@ -326,7 +326,7 @@ namespace MQTTnet.Server
|
||||
return Task.FromResult((IList<MqttClientStatus>)result);
|
||||
}
|
||||
|
||||
public Task<IList<MqttSessionStatus>> GetSessionStatusAsync()
|
||||
public Task<IList<MqttSessionStatus>> GetSessionsStatus()
|
||||
{
|
||||
var result = new List<MqttSessionStatus>();
|
||||
|
||||
@@ -614,20 +614,15 @@ namespace MQTTnet.Server
|
||||
// Create a new client (always required).
|
||||
lock (_clients)
|
||||
{
|
||||
_clients.TryGetValue(connectPacket.ClientId, out oldClient);
|
||||
}
|
||||
|
||||
if (oldClient != null)
|
||||
{
|
||||
// This will stop the current client from sending and receiving but remains the connection active
|
||||
// for a later DISCONNECT packet.
|
||||
oldClient.IsTakenOver = true;
|
||||
}
|
||||
_clients.TryGetValue(connectPacket.ClientId, out oldClient);
|
||||
if (oldClient != null)
|
||||
{
|
||||
// This will stop the current client from sending and receiving but remains the connection active
|
||||
// for a later DISCONNECT packet.
|
||||
oldClient.IsTakenOver = true;
|
||||
}
|
||||
|
||||
client = CreateClient(connectPacket, channelAdapter, session);
|
||||
|
||||
lock (_clients)
|
||||
{
|
||||
client = CreateClient(connectPacket, channelAdapter, session);
|
||||
_clients[connectPacket.ClientId] = client;
|
||||
}
|
||||
}
|
||||
|
||||
@@ -200,7 +200,7 @@ namespace MQTTnet.Server
|
||||
{
|
||||
ThrowIfNotStarted();
|
||||
|
||||
return _clientSessionsManager.GetClientStatusesAsync();
|
||||
return _clientSessionsManager.GetClientsStatus();
|
||||
}
|
||||
|
||||
public Task<IList<MqttApplicationMessage>> GetRetainedMessagesAsync()
|
||||
@@ -226,7 +226,7 @@ namespace MQTTnet.Server
|
||||
{
|
||||
ThrowIfNotStarted();
|
||||
|
||||
return _clientSessionsManager.GetSessionStatusAsync();
|
||||
return _clientSessionsManager.GetSessionsStatus();
|
||||
}
|
||||
|
||||
public Task InjectApplicationMessage(InjectedMqttApplicationMessage injectedApplicationMessage, CancellationToken cancellationToken = default)
|
||||
@@ -292,7 +292,7 @@ namespace MQTTnet.Server
|
||||
|
||||
_cancellationTokenSource.Cancel(false);
|
||||
|
||||
await _clientSessionsManager.CloseAllConnectionsAsync().ConfigureAwait(false);
|
||||
await _clientSessionsManager.CloseAllConnections().ConfigureAwait(false);
|
||||
|
||||
foreach (var adapter in _adapters)
|
||||
{
|
||||
|
||||
Reference in New Issue
Block a user