diff --git a/MQTTnet.sln b/MQTTnet.sln
index 6cb185dbe..9e3f0778b 100644
--- a/MQTTnet.sln
+++ b/MQTTnet.sln
@@ -18,12 +18,15 @@ Project("{2150E333-8FDC-42A3-9474-1A3956D46DE8}") = "Build", "Build", "{67C28AC1
appveyor.yml = appveyor.yml
Build\build.ps1 = Build\build.ps1
Build\MQTTnet.AspNetCore.nuspec = Build\MQTTnet.AspNetCore.nuspec
+ Build\MQTTnet.Extensions.ManagedClient.nuspec = Build\MQTTnet.Extensions.ManagedClient.nuspec
Build\MQTTnet.Extensions.Rpc.nuspec = Build\MQTTnet.Extensions.Rpc.nuspec
Build\MQTTnet.nuspec = Build\MQTTnet.nuspec
EndProjectSection
EndProject
Project("{2150E333-8FDC-42A3-9474-1A3956D46DE8}") = "Solution Items", "Solution Items", "{B3F60ECB-45BA-4C66-8903-8BB89CA67998}"
ProjectSection(SolutionItems) = preProject
+ .bettercodehub.yml = .bettercodehub.yml
+ appveyor.yml = appveyor.yml
LICENSE = LICENSE
README.md = README.md
EndProjectSection
@@ -40,6 +43,8 @@ Project("{9A19103F-16F7-4668-BE54-9A1E7A4F7556}") = "MQTTnet.Extensions.Rpc", "E
EndProject
Project("{9A19103F-16F7-4668-BE54-9A1E7A4F7556}") = "MQTTnet.Benchmarks", "Tests\MQTTnet.Benchmarks\MQTTnet.Benchmarks.csproj", "{998D04DD-7CB0-45F5-A393-E2495C16399E}"
EndProject
+Project("{9A19103F-16F7-4668-BE54-9A1E7A4F7556}") = "MQTTnet.Extensions.ManagedClient", "Extensions\MQTTnet.Extensions.ManagedClient\MQTTnet.Extensions.ManagedClient.csproj", "{C400533A-8EBA-4F0B-BF4D-295C3708604B}"
+EndProject
Global
GlobalSection(SolutionConfigurationPlatforms) = preSolution
Debug|Any CPU = Debug|Any CPU
@@ -186,6 +191,22 @@ Global
{998D04DD-7CB0-45F5-A393-E2495C16399E}.Release|x64.Build.0 = Release|Any CPU
{998D04DD-7CB0-45F5-A393-E2495C16399E}.Release|x86.ActiveCfg = Release|Any CPU
{998D04DD-7CB0-45F5-A393-E2495C16399E}.Release|x86.Build.0 = Release|Any CPU
+ {C400533A-8EBA-4F0B-BF4D-295C3708604B}.Debug|Any CPU.ActiveCfg = Debug|Any CPU
+ {C400533A-8EBA-4F0B-BF4D-295C3708604B}.Debug|Any CPU.Build.0 = Debug|Any CPU
+ {C400533A-8EBA-4F0B-BF4D-295C3708604B}.Debug|ARM.ActiveCfg = Debug|Any CPU
+ {C400533A-8EBA-4F0B-BF4D-295C3708604B}.Debug|ARM.Build.0 = Debug|Any CPU
+ {C400533A-8EBA-4F0B-BF4D-295C3708604B}.Debug|x64.ActiveCfg = Debug|Any CPU
+ {C400533A-8EBA-4F0B-BF4D-295C3708604B}.Debug|x64.Build.0 = Debug|Any CPU
+ {C400533A-8EBA-4F0B-BF4D-295C3708604B}.Debug|x86.ActiveCfg = Debug|Any CPU
+ {C400533A-8EBA-4F0B-BF4D-295C3708604B}.Debug|x86.Build.0 = Debug|Any CPU
+ {C400533A-8EBA-4F0B-BF4D-295C3708604B}.Release|Any CPU.ActiveCfg = Release|Any CPU
+ {C400533A-8EBA-4F0B-BF4D-295C3708604B}.Release|Any CPU.Build.0 = Release|Any CPU
+ {C400533A-8EBA-4F0B-BF4D-295C3708604B}.Release|ARM.ActiveCfg = Release|Any CPU
+ {C400533A-8EBA-4F0B-BF4D-295C3708604B}.Release|ARM.Build.0 = Release|Any CPU
+ {C400533A-8EBA-4F0B-BF4D-295C3708604B}.Release|x64.ActiveCfg = Release|Any CPU
+ {C400533A-8EBA-4F0B-BF4D-295C3708604B}.Release|x64.Build.0 = Release|Any CPU
+ {C400533A-8EBA-4F0B-BF4D-295C3708604B}.Release|x86.ActiveCfg = Release|Any CPU
+ {C400533A-8EBA-4F0B-BF4D-295C3708604B}.Release|x86.Build.0 = Release|Any CPU
EndGlobalSection
GlobalSection(SolutionProperties) = preSolution
HideSolutionNode = FALSE
@@ -199,6 +220,7 @@ Global
{F10C4060-F7EE-4A83-919F-FF723E72F94A} = {32A630A7-2598-41D7-B625-204CD906F5FB}
{C444E9C8-95FA-430E-9126-274129DE16CD} = {12816BCC-AF9E-44A9-9AE5-C246AF2A0587}
{998D04DD-7CB0-45F5-A393-E2495C16399E} = {9248C2E1-B9D6-40BF-81EC-86004D7765B4}
+ {C400533A-8EBA-4F0B-BF4D-295C3708604B} = {12816BCC-AF9E-44A9-9AE5-C246AF2A0587}
EndGlobalSection
GlobalSection(ExtensibilityGlobals) = postSolution
SolutionGuid = {07536672-5CBC-4BE3-ACE0-708A431A7894}
diff --git a/README.md b/README.md
index cff5490fd..52735cae4 100644
--- a/README.md
+++ b/README.md
@@ -21,7 +21,7 @@ MQTTnet is a high performance .NET library for MQTT based communication. It prov
* Performance optimized (processing ~60.000 messages / second)*
* Interfaces included for mocking and testing
* Access to internal trace messages
-* Unit tested (~80 tests)
+* Unit tested (~90 tests)
\* Tested on local machine (Intel i7 8700K) with MQTTnet client and server running in the same process using the TCP channel. The app for verification is part of this repository and stored in _/Tests/MQTTnet.TestApp.NetCore_.
diff --git a/Tests/MQTTnet.Benchmarks/ChannelAdapterBenchmark.cs b/Tests/MQTTnet.Benchmarks/ChannelAdapterBenchmark.cs
index 726f5e0fc..577d6960e 100644
--- a/Tests/MQTTnet.Benchmarks/ChannelAdapterBenchmark.cs
+++ b/Tests/MQTTnet.Benchmarks/ChannelAdapterBenchmark.cs
@@ -1,6 +1,5 @@
using BenchmarkDotNet.Attributes;
using MQTTnet.Adapter;
-using MQTTnet.Core.Internal;
using MQTTnet.Diagnostics;
using MQTTnet.Internal;
using MQTTnet.Packets;
diff --git a/Tests/MQTTnet.Benchmarks/SerializerBenchmark.cs b/Tests/MQTTnet.Benchmarks/SerializerBenchmark.cs
index 389998f6f..06e7b397d 100644
--- a/Tests/MQTTnet.Benchmarks/SerializerBenchmark.cs
+++ b/Tests/MQTTnet.Benchmarks/SerializerBenchmark.cs
@@ -8,7 +8,6 @@
using System.Threading;
using System.IO;
using MQTTnet.Adapter;
-using MQTTnet.Core.Internal;
namespace MQTTnet.Benchmarks
{
@@ -55,7 +54,7 @@ public void Deserialize_10000_Messages()
using (var bodyStream = new MemoryStream(Join(_serializedPacket), (int)headerStream.Position, header.RemainingLength))
{
- _serializer.Deserialize(new ReceivedMqttPacket(header.Flags, bodyStream));
+ _serializer.Deserialize(new ReceivedMqttPacket(header.Flags, new MqttPacketBodyReader(bodyStream.ToArray())));
}
}
}
diff --git a/Tests/MQTTnet.Benchmarks/Tcp/BufferExtensions.cs b/Tests/MQTTnet.Benchmarks/Tcp/BufferExtensions.cs
index 0a2c19e83..879306c11 100644
--- a/Tests/MQTTnet.Benchmarks/Tcp/BufferExtensions.cs
+++ b/Tests/MQTTnet.Benchmarks/Tcp/BufferExtensions.cs
@@ -1,9 +1,7 @@
using System;
-using System.Collections.Generic;
using System.Runtime.InteropServices;
-using System.Text;
-namespace Playground.Client.Mqtt.Tcp
+namespace MQTTnet.Benchmarks.Tcp
{
public static class BufferExtensions
{
diff --git a/Tests/MQTTnet.Benchmarks/Tcp/SocketAwaitable.cs b/Tests/MQTTnet.Benchmarks/Tcp/SocketAwaitable.cs
index dcaaaf41d..2271bd76e 100644
--- a/Tests/MQTTnet.Benchmarks/Tcp/SocketAwaitable.cs
+++ b/Tests/MQTTnet.Benchmarks/Tcp/SocketAwaitable.cs
@@ -1,14 +1,12 @@
using System;
-using System.Collections.Generic;
using System.Diagnostics;
using System.IO.Pipelines;
using System.Net.Sockets;
using System.Runtime.CompilerServices;
-using System.Text;
using System.Threading;
using System.Threading.Tasks;
-namespace Playground.Client.Mqtt.Tcp
+namespace MQTTnet.Benchmarks.Tcp
{
public class SocketAwaitable : ICriticalNotifyCompletion
{
diff --git a/Tests/MQTTnet.Benchmarks/Tcp/SocketReceiver.cs b/Tests/MQTTnet.Benchmarks/Tcp/SocketReceiver.cs
index e2f19c074..bc8e5c03f 100644
--- a/Tests/MQTTnet.Benchmarks/Tcp/SocketReceiver.cs
+++ b/Tests/MQTTnet.Benchmarks/Tcp/SocketReceiver.cs
@@ -1,7 +1,6 @@
using System;
using System.IO.Pipelines;
using System.Net.Sockets;
-using Playground.Client.Mqtt.Tcp;
namespace MQTTnet.Benchmarks.Tcp
{
diff --git a/Tests/MQTTnet.Benchmarks/Tcp/SocketSender.cs b/Tests/MQTTnet.Benchmarks/Tcp/SocketSender.cs
index 475fa6851..7cb1bc1d6 100644
--- a/Tests/MQTTnet.Benchmarks/Tcp/SocketSender.cs
+++ b/Tests/MQTTnet.Benchmarks/Tcp/SocketSender.cs
@@ -4,7 +4,6 @@
using System.Diagnostics;
using System.IO.Pipelines;
using System.Net.Sockets;
-using Playground.Client.Mqtt.Tcp;
namespace MQTTnet.Benchmarks.Tcp
{
diff --git a/Tests/MQTTnet.Benchmarks/Tcp/TcpConnection.cs b/Tests/MQTTnet.Benchmarks/Tcp/TcpConnection.cs
index e73067c71..96b1d8586 100644
--- a/Tests/MQTTnet.Benchmarks/Tcp/TcpConnection.cs
+++ b/Tests/MQTTnet.Benchmarks/Tcp/TcpConnection.cs
@@ -6,7 +6,6 @@
using System.Net.Sockets;
using System.Threading.Tasks;
using MQTTnet.Exceptions;
-using Playground.Client.Mqtt.Tcp;
namespace MQTTnet.Benchmarks.Tcp
{
diff --git a/Tests/MQTTnet.Core.Tests/MqttPacketReaderTests.cs b/Tests/MQTTnet.Core.Tests/MqttPacketReaderTests.cs
index 58ef6b113..e3e1ccd39 100644
--- a/Tests/MQTTnet.Core.Tests/MqttPacketReaderTests.cs
+++ b/Tests/MQTTnet.Core.Tests/MqttPacketReaderTests.cs
@@ -1,8 +1,8 @@
using System.IO;
using System.Threading;
using Microsoft.VisualStudio.TestTools.UnitTesting;
-using MQTTnet.Core.Internal;
using MQTTnet.Exceptions;
+using MQTTnet.Internal;
using MQTTnet.Serializer;
namespace MQTTnet.Core.Tests
diff --git a/Tests/MQTTnet.Core.Tests/MqttPacketSerializerTests.cs b/Tests/MQTTnet.Core.Tests/MqttPacketSerializerTests.cs
index 6ba3b1249..40aa95352 100644
--- a/Tests/MQTTnet.Core.Tests/MqttPacketSerializerTests.cs
+++ b/Tests/MQTTnet.Core.Tests/MqttPacketSerializerTests.cs
@@ -4,7 +4,7 @@
using System.Threading;
using Microsoft.VisualStudio.TestTools.UnitTesting;
using MQTTnet.Adapter;
-using MQTTnet.Core.Internal;
+using MQTTnet.Internal;
using MQTTnet.Packets;
using MQTTnet.Protocol;
using MQTTnet.Serializer;
@@ -422,7 +422,7 @@ private static void DeserializeAndCompare(MqttBasePacket packet, string expected
using (var bodyStream = new MemoryStream(Join(buffer1), (int)headerStream.Position, header.RemainingLength))
{
- var deserializedPacket = serializer.Deserialize(new ReceivedMqttPacket(header.Flags, bodyStream));
+ var deserializedPacket = serializer.Deserialize(new ReceivedMqttPacket(header.Flags, new MqttPacketBodyReader(bodyStream.ToArray())));
var buffer2 = serializer.Serialize(deserializedPacket);
Assert.AreEqual(expectedBase64Value, Convert.ToBase64String(Join(buffer2)));
diff --git a/Tests/MQTTnet.TestApp.NetCore/ClientFlowTest.cs b/Tests/MQTTnet.TestApp.NetCore/ClientFlowTest.cs
new file mode 100644
index 000000000..4b1662369
--- /dev/null
+++ b/Tests/MQTTnet.TestApp.NetCore/ClientFlowTest.cs
@@ -0,0 +1,47 @@
+using System;
+using System.Threading.Tasks;
+using MQTTnet.Client;
+
+namespace MQTTnet.TestApp.NetCore
+{
+ public static class ClientFlowTest
+ {
+ public static async Task RunAsync()
+ {
+ MqttNetConsoleLogger.ForwardToConsole();
+ try
+ {
+ var factory = new MqttFactory();
+ var client = factory.CreateMqttClient();
+
+ var options = new MqttClientOptionsBuilder()
+ .WithTcpServer("localhost")
+ .Build();
+
+ Console.WriteLine("BEFORE CONNECT");
+ await client.ConnectAsync(options);
+ Console.WriteLine("AFTER CONNECT");
+
+ Console.WriteLine("BEFORE SUBSCRIBE");
+ await client.SubscribeAsync("test/topic");
+ Console.WriteLine("AFTER SUBSCRIBE");
+
+ Console.WriteLine("BEFORE PUBLISH");
+ await client.PublishAsync("test/topic", "payload");
+ Console.WriteLine("AFTER PUBLISH");
+
+ await Task.Delay(1000);
+
+ Console.WriteLine("BEFORE DISCONNECT");
+ await client.DisconnectAsync();
+ Console.WriteLine("AFTER DISCONNECT");
+
+ Console.WriteLine("FINISHED");
+ }
+ catch (Exception ex)
+ {
+ Console.WriteLine(ex);
+ }
+ }
+ }
+}
diff --git a/Tests/MQTTnet.TestApp.NetCore/MQTTnet.TestApp.NetCore.csproj b/Tests/MQTTnet.TestApp.NetCore/MQTTnet.TestApp.NetCore.csproj
index 43fd8c87e..cf1aa34e8 100644
--- a/Tests/MQTTnet.TestApp.NetCore/MQTTnet.TestApp.NetCore.csproj
+++ b/Tests/MQTTnet.TestApp.NetCore/MQTTnet.TestApp.NetCore.csproj
@@ -15,6 +15,7 @@
+
diff --git a/Tests/MQTTnet.TestApp.NetCore/ManagedClientTest.cs b/Tests/MQTTnet.TestApp.NetCore/ManagedClientTest.cs
index 4ecca0ff7..8efdebe0c 100644
--- a/Tests/MQTTnet.TestApp.NetCore/ManagedClientTest.cs
+++ b/Tests/MQTTnet.TestApp.NetCore/ManagedClientTest.cs
@@ -4,7 +4,7 @@
using Newtonsoft.Json;
using System.Collections.Generic;
using MQTTnet.Client;
-using MQTTnet.ManagedClient;
+using MQTTnet.Extensions.ManagedClient;
using MQTTnet.Protocol;
namespace MQTTnet.TestApp.NetCore
diff --git a/Tests/MQTTnet.TestApp.NetCore/Program.cs b/Tests/MQTTnet.TestApp.NetCore/Program.cs
index 270b16ed1..f8a5d275f 100644
--- a/Tests/MQTTnet.TestApp.NetCore/Program.cs
+++ b/Tests/MQTTnet.TestApp.NetCore/Program.cs
@@ -21,6 +21,7 @@ public static void Main()
Console.WriteLine("4 = Start managed client");
Console.WriteLine("5 = Start public broker test");
Console.WriteLine("6 = Start server & client");
+ Console.WriteLine("7 = Client flow test");
var pressedKey = Console.ReadKey(true);
if (pressedKey.KeyChar == '1')
@@ -47,6 +48,10 @@ public static void Main()
{
Task.Run(ServerAndClientTest.RunAsync);
}
+ else if (pressedKey.KeyChar == '7')
+ {
+ Task.Run(ClientFlowTest.RunAsync);
+ }
Thread.Sleep(Timeout.Infinite);
}
diff --git a/Tests/MQTTnet.TestApp.UniversalWindows/MQTTnet.TestApp.UniversalWindows.csproj b/Tests/MQTTnet.TestApp.UniversalWindows/MQTTnet.TestApp.UniversalWindows.csproj
index 0a69b342c..3bf7ee804 100644
--- a/Tests/MQTTnet.TestApp.UniversalWindows/MQTTnet.TestApp.UniversalWindows.csproj
+++ b/Tests/MQTTnet.TestApp.UniversalWindows/MQTTnet.TestApp.UniversalWindows.csproj
@@ -127,6 +127,10 @@
+
+ {C400533A-8EBA-4F0B-BF4D-295C3708604B}
+ MQTTnet.Extensions.ManagedClient
+
{c444e9c8-95fa-430e-9126-274129de16cd}
MQTTnet.Extensions.Rpc
diff --git a/Tests/MQTTnet.TestApp.UniversalWindows/MainPage.xaml.cs b/Tests/MQTTnet.TestApp.UniversalWindows/MainPage.xaml.cs
index 52db69e33..76f947d45 100644
--- a/Tests/MQTTnet.TestApp.UniversalWindows/MainPage.xaml.cs
+++ b/Tests/MQTTnet.TestApp.UniversalWindows/MainPage.xaml.cs
@@ -8,9 +8,9 @@
using MQTTnet.Client;
using MQTTnet.Diagnostics;
using MQTTnet.Exceptions;
+using MQTTnet.Extensions.ManagedClient;
using MQTTnet.Extensions.Rpc;
using MQTTnet.Implementations;
-using MQTTnet.ManagedClient;
using MQTTnet.Protocol;
using MQTTnet.Server;
using MqttClientConnectedEventArgs = MQTTnet.Client.MqttClientConnectedEventArgs;
@@ -613,7 +613,6 @@ private async Task WikiCode()
await mqttClient.SubscribeAsync(new TopicFilterBuilder().WithTopic("my/topic").Build());
await mqttClient.StartAsync(options);
}
-
}
}
}