From abb216c055571b0b587311742a77e80bd35f1ef4 Mon Sep 17 00:00:00 2001 From: Christian Date: Wed, 21 Feb 2018 20:43:22 +0100 Subject: [PATCH] Fix retained message handling --- .../Server/MqttClientSessionsManager.cs | 5 +++-- .../Server/MqttRetainedMessagesManager.cs | 10 ++-------- 2 files changed, 5 insertions(+), 10 deletions(-) diff --git a/Frameworks/MQTTnet.NetStandard/Server/MqttClientSessionsManager.cs b/Frameworks/MQTTnet.NetStandard/Server/MqttClientSessionsManager.cs index d580dd2..a9e68bc 100644 --- a/Frameworks/MQTTnet.NetStandard/Server/MqttClientSessionsManager.cs +++ b/Frameworks/MQTTnet.NetStandard/Server/MqttClientSessionsManager.cs @@ -220,7 +220,8 @@ namespace MQTTnet.Server private MqttApplicationMessage InterceptApplicationMessage(MqttClientSession senderClientSession, MqttApplicationMessage applicationMessage) { - if (_options.ApplicationMessageInterceptor == null) + var interceptor = _options.ApplicationMessageInterceptor; + if (interceptor == null) { return applicationMessage; } @@ -229,7 +230,7 @@ namespace MQTTnet.Server senderClientSession.ClientId, applicationMessage); - _options.ApplicationMessageInterceptor(interceptorContext); + interceptor(interceptorContext); return interceptorContext.ApplicationMessage; } diff --git a/Frameworks/MQTTnet.NetStandard/Server/MqttRetainedMessagesManager.cs b/Frameworks/MQTTnet.NetStandard/Server/MqttRetainedMessagesManager.cs index 7b90209..11cac24 100644 --- a/Frameworks/MQTTnet.NetStandard/Server/MqttRetainedMessagesManager.cs +++ b/Frameworks/MQTTnet.NetStandard/Server/MqttRetainedMessagesManager.cs @@ -4,7 +4,6 @@ using System.Linq; using System.Threading; using System.Threading.Tasks; using MQTTnet.Diagnostics; -using MQTTnet.Packets; namespace MQTTnet.Server { @@ -68,7 +67,7 @@ namespace MQTTnet.Server } } - public async Task> GetSubscribedMessagesAsync(MqttSubscribePacket subscribePacket) + public async Task> GetSubscribedMessagesAsync(ICollection topicFilters) { var retainedMessages = new List(); @@ -77,13 +76,8 @@ namespace MQTTnet.Server { foreach (var retainedMessage in _retainedMessages.Values) { - foreach (var topicFilter in subscribePacket.TopicFilters) + foreach (var topicFilter in topicFilters) { - if (retainedMessage.QualityOfServiceLevel < topicFilter.QualityOfServiceLevel) - { - continue; - } - if (!MqttTopicFilterComparer.IsMatch(retainedMessage.Topic, topicFilter.Topic)) { continue;