Source/MQTTnet/Server/MqttClientSubscriptionsManager.cs파일 보기
@@ -4,6 +4,7 @@ using System.Linq;
using System.Threading.Tasks;
using MQTTnet.Packets;
using MQTTnet.Protocol;
using static MQTTnet.Server.MqttClientSessionsManager;
namespace MQTTnet.Server
{
@@ -16,6 +17,7 @@ namespace MQTTnet.Server
public MqttClientSubscriptionsManager(MqttClientSession clientSession, MqttServerEventDispatcher eventDispatcher, IMqttServerOptions serverOptions)
{
TestLogger.WriteLine("sub manager");
_clientSession = clientSession ?? throw new ArgumentNullException(nameof(clientSession));
// TODO: Consider removing the server options here and build a new class "ISubscriptionInterceptor" and just pass it. The instance is generated in the root server class upon start.
@@ -25,6 +27,7 @@ namespace MQTTnet.Server
public async Task<MqttClientSubscribeResult> SubscribeAsync(MqttSubscribePacket subscribePacket, MqttConnectPacket connectPacket)
{
TestLogger.WriteLine("sub1");
if (subscribePacket == null) throw new ArgumentNullException(nameof(subscribePacket));
if (connectPacket == null) throw new ArgumentNullException(nameof(connectPacket));
@@ -76,6 +79,7 @@ namespace MQTTnet.Server
public async Task SubscribeAsync(IEnumerable<TopicFilter> topicFilters)
{
TestLogger.WriteLine("sub2");
if (topicFilters == null) throw new ArgumentNullException(nameof(topicFilters));
foreach (var topicFilter in topicFilters)
@@ -100,6 +104,7 @@ namespace MQTTnet.Server
public async Task<MqttUnsubAckPacket> UnsubscribeAsync(MqttUnsubscribePacket unsubscribePacket)
{
TestLogger.WriteLine("unsub1");
if (unsubscribePacket == null) throw new ArgumentNullException(nameof(unsubscribePacket));
var unsubAckPacket = new MqttUnsubAckPacket
@@ -132,6 +137,7 @@ namespace MQTTnet.Server
public Task UnsubscribeAsync(IEnumerable<string> topicFilters)
{
TestLogger.WriteLine("unsub2");
if (topicFilters == null) throw new ArgumentNullException(nameof(topicFilters));
lock (_subscriptions)
@@ -147,6 +153,7 @@ namespace MQTTnet.Server
public CheckSubscriptionsResult CheckSubscriptions(string topic, MqttQualityOfServiceLevel qosLevel)
{
TestLogger.WriteLine("check");
var qosLevels = new HashSet<MqttQualityOfServiceLevel>();
lock (_subscriptions)
+ 2- 0
Source/MQTTnet/Server/MqttServerEventDispatcher.cs파일 보기
@@ -2,6 +2,7 @@
using System.Threading.Tasks;
using MQTTnet.Client.Receiving;
using MQTTnet.Diagnostics;
using static MQTTnet.Server.MqttClientSessionsManager;
namespace MQTTnet.Server
{
@@ -55,6 +56,7 @@ namespace MQTTnet.Server
public Task HandleClientSubscribedTopicAsync(string clientId, TopicFilter topicFilter)
{
TestLogger.WriteLine("handle sub");
var handler = ClientSubscribedTopicHandler;
if (handler == null)
{
+ 3- 2
Tests/MQTTnet.Core.Tests/Server_Status_Tests.cs파일 보기
@@ -6,6 +6,7 @@ using MQTTnet.Tests.Mockups;
using MQTTnet.Client;
using MQTTnet.Protocol;
using MQTTnet.Server;
using System.Threading;
namespace MQTTnet.Tests
{
@@ -55,10 +56,10 @@ namespace MQTTnet.Tests
var c1 = await testEnvironment.ConnectClientAsync(new MqttClientOptionsBuilder().WithClientId("client1"));
await Task.Delay(500);
await Task.Delay(1000);
var clientStatus = await server.GetClientStatusAsync();