Merge branch 'master' of https://github.com/chkr1011/MQTTnet into feature/Reason_Code_In_Subscription_Interceptor

# Conflicts:
#	Build/MQTTnet.nuspec
#	Source/MQTTnet/Server/Internal/MqttClientSessionsManager.cs
This commit is contained in:
Christian
2021-10-29 21:58:57 +02:00
parent d5237bb3f5
commit 6bad9f183c
191 changed files with 601 additions and 981 deletions
@@ -1,8 +1,7 @@
using System;
using System.Threading.Tasks;
using MQTTnet.Client;
using MQTTnet.Client.Options;
using MQTTnet.Diagnostics.Logger;
using MQTTnet.Diagnostics;
namespace MQTTnet.TestApp.NetCore
{
+7 -7
View File
@@ -1,13 +1,11 @@
using MQTTnet.Client;
using MQTTnet.Client.Connecting;
using MQTTnet.Client.Disconnecting;
using MQTTnet.Client.Options;
using MQTTnet.Client.Receiving;
using MQTTnet.Protocol;
using System;
using System.Text;
using System.Threading.Tasks;
using MQTTnet.Diagnostics.Logger;
using MQTTnet.Diagnostics;
using MQTTnet.Implementations;
using MQTTnet.Packets;
namespace MQTTnet.TestApp.NetCore
{
@@ -30,7 +28,7 @@ namespace MQTTnet.TestApp.NetCore
}
};
client.ApplicationMessageReceivedHandler = new MqttApplicationMessageReceivedHandlerDelegate(e =>
client.ApplicationMessageReceivedAsync += e =>
{
Console.WriteLine("### RECEIVED APPLICATION MESSAGE ###");
Console.WriteLine($"+ Topic = {e.ApplicationMessage.Topic}");
@@ -38,7 +36,9 @@ namespace MQTTnet.TestApp.NetCore
Console.WriteLine($"+ QoS = {e.ApplicationMessage.QualityOfServiceLevel}");
Console.WriteLine($"+ Retain = {e.ApplicationMessage.Retain}");
Console.WriteLine();
});
return PlatformAbstractionLayer.CompletedTask;
};
client.ConnectedHandler = new MqttClientConnectedHandlerDelegate(async e =>
{
@@ -3,9 +3,10 @@ using System.Threading.Tasks;
using System.IO;
using Newtonsoft.Json;
using System.Collections.Generic;
using MQTTnet.Client.Options;
using MQTTnet.Client.Receiving;
using MQTTnet.Client;
using MQTTnet.Extensions.ManagedClient;
using MQTTnet.Implementations;
using MQTTnet.Packets;
using MQTTnet.Protocol;
namespace MQTTnet.TestApp.NetCore
@@ -35,10 +36,11 @@ namespace MQTTnet.TestApp.NetCore
try
{
var managedClient = new MqttFactory().CreateManagedMqttClient();
managedClient.ApplicationMessageReceivedHandler = new MqttApplicationMessageReceivedHandlerDelegate(e =>
managedClient.ApplicationMessageReceivedAsync += e =>
{
Console.WriteLine(">> RECEIVED: " + e.ApplicationMessage.Topic);
});
return PlatformAbstractionLayer.CompletedTask;
};
await managedClient.StartAsync(options);
@@ -69,7 +71,7 @@ namespace MQTTnet.TestApp.NetCore
public class ClientRetainedMessageHandler : IManagedMqttClientStorage
{
private const string Filename = @"RetainedMessages.json";
const string Filename = @"RetainedMessages.json";
public Task SaveQueuedMessagesAsync(IList<ManagedMqttApplicationMessage> messages)
{
@@ -1,6 +1,6 @@
using System;
using System.Text;
using MQTTnet.Diagnostics.Logger;
using MQTTnet.Diagnostics;
namespace MQTTnet.TestApp.NetCore
{
File diff suppressed because one or more lines are too long
+5 -5
View File
@@ -1,5 +1,4 @@
using MQTTnet.Client.Options;
using MQTTnet.Diagnostics;
using MQTTnet.Diagnostics;
using MQTTnet.Server;
using Newtonsoft.Json;
using System;
@@ -9,7 +8,7 @@ using System.Net.Security;
using System.Threading;
using System.Threading.Tasks;
using MQTTnet.Client;
using MQTTnet.Diagnostics.Runtime;
using MQTTnet.Implementations;
namespace MQTTnet.TestApp.NetCore
{
@@ -110,10 +109,11 @@ namespace MQTTnet.TestApp.NetCore
.Build();
//mqttClient.ApplicationMessageReceived += (s, e) => // version 2.8.5
mqttClient.UseApplicationMessageReceivedHandler(e => // version 3.0.0+
mqttClient.ApplicationMessageReceivedAsync += e => // version 3.0.0+
{
Interlocked.Increment(ref _count);
});
return PlatformAbstractionLayer.CompletedTask;
};
//mqttClient.Connected += async (s, e) => // version 2.8.5
mqttClient.UseConnectedHandler(async e => // version 3.0.0+
@@ -1,13 +1,10 @@
using MQTTnet.Client;
using System;
using System.IO;
using System.Net;
using System.Security.Authentication;
using System.Threading;
using System.Threading.Tasks;
using MQTTnet.Client.Options;
using MQTTnet.Client.Receiving;
using MQTTnet.Formatter;
using MQTTnet.Implementations;
using MQTTnet.Protocol;
namespace MQTTnet.TestApp.NetCore
@@ -129,7 +126,7 @@ namespace MQTTnet.TestApp.NetCore
Console.ReadLine();
}
private static async Task ExecuteTestAsync(string name, IMqttClientOptions options)
static async Task ExecuteTestAsync(string name, IMqttClientOptions options)
{
try
{
@@ -140,7 +137,11 @@ namespace MQTTnet.TestApp.NetCore
var topic = Guid.NewGuid().ToString();
MqttApplicationMessage receivedMessage = null;
client.ApplicationMessageReceivedHandler = new MqttApplicationMessageReceivedHandlerDelegate(e => receivedMessage = e.ApplicationMessage);
client.ApplicationMessageReceivedAsync += e =>
{
receivedMessage = e.ApplicationMessage;
return PlatformAbstractionLayer.CompletedTask;
};
await client.ConnectAsync(options);
await client.SubscribeAsync(topic, MqttQualityOfServiceLevel.AtLeastOnce);
@@ -164,7 +165,7 @@ namespace MQTTnet.TestApp.NetCore
}
}
private static void Write(string message, ConsoleColor color)
static void Write(string message, ConsoleColor color)
{
Console.ForegroundColor = color;
Console.Write(message);
@@ -1,8 +1,7 @@
using System.Threading;
using System.Threading.Tasks;
using MQTTnet.Client;
using MQTTnet.Client.Options;
using MQTTnet.Diagnostics.Logger;
using MQTTnet.Diagnostics;
using MQTTnet.Server;
namespace MQTTnet.TestApp.NetCore
+1 -2
View File
@@ -1,11 +1,10 @@
using System;
using System.Text;
using System.Threading.Tasks;
using MQTTnet.Diagnostics.Logger;
using MQTTnet.Diagnostics;
using MQTTnet.Implementations;
using MQTTnet.Protocol;
using MQTTnet.Server;
using MQTTnet.Server.Internal;
namespace MQTTnet.TestApp.NetCore
{