Browse Source

Fixes chkr1011's refactoing and pass all tests

release/3.x.x
Sébastien Warin 6 years ago
parent
commit
932aa1fd39
2 changed files with 5 additions and 3 deletions
  1. +4
    -2
      Frameworks/MQTTnet.NetStandard/Server/MqttClientSessionsManager.cs
  2. +1
    -1
      Frameworks/MQTTnet.NetStandard/Server/MqttRetainedMessagesManager.cs

+ 4
- 2
Frameworks/MQTTnet.NetStandard/Server/MqttClientSessionsManager.cs View File

@@ -136,9 +136,9 @@ namespace MQTTnet.Server
return Task.FromResult((IList<IMqttClientSessionStatus>)result); return Task.FromResult((IList<IMqttClientSessionStatus>)result);
} }


public void StartDispatchApplicationMessage(MqttClientSession senderClientSession, MqttApplicationMessage applicationMessage)
public Task StartDispatchApplicationMessage(MqttClientSession senderClientSession, MqttApplicationMessage applicationMessage)
{ {
Task.Run(() => DispatchApplicationMessageAsync(senderClientSession, applicationMessage));
return DispatchApplicationMessageAsync(senderClientSession, applicationMessage);
} }


public Task SubscribeAsync(string clientId, IList<TopicFilter> topicFilters) public Task SubscribeAsync(string clientId, IList<TopicFilter> topicFilters)
@@ -237,6 +237,7 @@ namespace MQTTnet.Server
{ {
try try
{ {
_logger.Verbose($"DispatchApplicationMessageAsync");
var interceptorContext = InterceptApplicationMessage(senderClientSession, applicationMessage); var interceptorContext = InterceptApplicationMessage(senderClientSession, applicationMessage);
if (interceptorContext.CloseConnection) if (interceptorContext.CloseConnection)
{ {
@@ -257,6 +258,7 @@ namespace MQTTnet.Server


foreach (var clientSession in _sessions.Values) foreach (var clientSession in _sessions.Values)
{ {
_logger.Verbose($"DispatchApplicationMessageAsync for {clientSession.ClientId} ");
clientSession.EnqueueApplicationMessage(applicationMessage); clientSession.EnqueueApplicationMessage(applicationMessage);
} }
} }


+ 1
- 1
Frameworks/MQTTnet.NetStandard/Server/MqttRetainedMessagesManager.cs View File

@@ -82,7 +82,7 @@ namespace MQTTnet.Server
{ {
var saveIsRequired = false; var saveIsRequired = false;


if (applicationMessage.Payload?.Length > 0)
if (applicationMessage.Payload?.Length == 0)
{ {
saveIsRequired = _messages.TryRemove(applicationMessage.Topic, out _); saveIsRequired = _messages.TryRemove(applicationMessage.Topic, out _);
_logger.Info("Client '{0}' cleared retained message for topic '{1}'.", clientId, applicationMessage.Topic); _logger.Info("Client '{0}' cleared retained message for topic '{1}'.", clientId, applicationMessage.Topic);


Loading…
Cancel
Save