diff --git a/Build/MQTTnet.AspNetCore.nuspec b/Build/MQTTnet.AspNetCore.nuspec
index 9f595626..669f205c 100644
--- a/Build/MQTTnet.AspNetCore.nuspec
+++ b/Build/MQTTnet.AspNetCore.nuspec
@@ -13,11 +13,9 @@
* Updated to MQTTnet 2.8.0.
Copyright Christian Kratky 2016-2018
- MQTT Message Queue Telemetry Transport MQTTClient MQTTServer Server MQTTBroker Broker NETStandard IoT InternetOfThings Messaging Hardware Arduino Sensor Actuator M2M ESP Smart Home Cities Automation Xamarin
+ MQTT Message Queue Telemetry Transport MQTTClient MQTTServer Server MQTTBroker Broker NETStandard IoT InternetOfThings Messaging Hardware Arduino Sensor Actuator M2M ESP Smart Home Cities Automation Xamarin
-
-
-
+
diff --git a/Build/MQTTnet.Extensions.ManagedClient.nuspec b/Build/MQTTnet.Extensions.ManagedClient.nuspec
index e6815541..6d7f7f69 100644
--- a/Build/MQTTnet.Extensions.ManagedClient.nuspec
+++ b/Build/MQTTnet.Extensions.ManagedClient.nuspec
@@ -15,24 +15,7 @@
Copyright Christian Kratky 2016-2018
MQTT Message Queue Telemetry Transport MQTTClient MQTTServer Server MQTTBroker Broker NETStandard IoT InternetOfThings Messaging Hardware Arduino Sensor Actuator M2M ESP Smart Home Cities Automation Xamarin
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
+
@@ -48,6 +31,8 @@
-
+
+
+
\ No newline at end of file
diff --git a/Build/MQTTnet.Extensions.Rpc.nuspec b/Build/MQTTnet.Extensions.Rpc.nuspec
index f8667c44..d7eddb00 100644
--- a/Build/MQTTnet.Extensions.Rpc.nuspec
+++ b/Build/MQTTnet.Extensions.Rpc.nuspec
@@ -15,24 +15,7 @@
Copyright Christian Kratky 2016-2018
MQTT Message Queue Telemetry Transport MQTTClient MQTTServer Server MQTTBroker Broker NETStandard IoT InternetOfThings Messaging Hardware Arduino Sensor Actuator M2M ESP Smart Home Cities Automation Xamarin
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
+
@@ -48,6 +31,8 @@
-
+
+
+
\ No newline at end of file
diff --git a/Build/MQTTnet.nuspec b/Build/MQTTnet.nuspec
index 25c31fb5..556957d9 100644
--- a/Build/MQTTnet.nuspec
+++ b/Build/MQTTnet.nuspec
@@ -48,7 +48,7 @@
-
+
@@ -69,6 +69,8 @@
-
+
+
+
\ No newline at end of file
diff --git a/Build/build.ps1 b/Build/build.ps1
index 59f3112c..0b6f074f 100644
--- a/Build/build.ps1
+++ b/Build/build.ps1
@@ -36,8 +36,8 @@ if ($path) {
Remove-Item .\NuGet -Force -Recurse -ErrorAction SilentlyContinue
New-Item -ItemType Directory -Force -Path .\NuGet
- .\NuGet.exe pack MQTTnet.nuspec -Verbosity detailed -Symbols -OutputDir "NuGet" -Version $nugetVersion
- .\NuGet.exe pack MQTTnet.AspNetCore.nuspec -Verbosity detailed -Symbols -OutputDir "NuGet" -Version $nugetVersion
- .\NuGet.exe pack MQTTnet.Extensions.Rpc.nuspec -Verbosity detailed -Symbols -OutputDir "NuGet" -Version $nugetVersion
- .\NuGet.exe pack MQTTnet.Extensions.ManagedClient.nuspec -Verbosity detailed -Symbols -OutputDir "NuGet" -Version $nugetVersion
+ .\nuget.exe pack MQTTnet.nuspec -Verbosity detailed -Symbols -OutputDir "NuGet" -Version $nugetVersion
+ .\nuget.exe pack MQTTnet.AspNetCore.nuspec -Verbosity detailed -Symbols -OutputDir "NuGet" -Version $nugetVersion
+ .\nuget.exe pack MQTTnet.Extensions.Rpc.nuspec -Verbosity detailed -Symbols -OutputDir "NuGet" -Version $nugetVersion
+ .\nuget.exe pack MQTTnet.Extensions.ManagedClient.nuspec -Verbosity detailed -Symbols -OutputDir "NuGet" -Version $nugetVersion
}
\ No newline at end of file
diff --git a/Build/upload.ps1 b/Build/upload.ps1
new file mode 100644
index 00000000..a7cb1728
--- /dev/null
+++ b/Build/upload.ps1
@@ -0,0 +1,9 @@
+param([string]$apiKey)
+
+$files = Get-ChildItem -Path ".\NuGet" -Filter "*.nupkg"
+foreach ($file in $files)
+{
+ Write-Host "Uploading: " $file
+
+ .\nuget.exe push $file.Fullname $apiKey -NoSymbols -Source https://api.nuget.org/v3/index.json
+}
\ No newline at end of file
diff --git a/MQTTnet.sln b/MQTTnet.sln
index 0e0e60c3..a46c295b 100644
--- a/MQTTnet.sln
+++ b/MQTTnet.sln
@@ -20,6 +20,7 @@ Project("{2150E333-8FDC-42A3-9474-1A3956D46DE8}") = "Build", "Build", "{67C28AC1
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
+ Build\upload.ps1 = Build\upload.ps1
EndProjectSection
EndProject
Project("{2150E333-8FDC-42A3-9474-1A3956D46DE8}") = "Solution Items", "Solution Items", "{B3F60ECB-45BA-4C66-8903-8BB89CA67998}"
@@ -74,6 +75,7 @@ Global
{A7FF0C91-25DE-4BA6-B39E-F54E8DADF1CC}.Release|x86.Build.0 = Release|Any CPU
{FF1F72D6-9524-4422-9497-3CC0002216ED}.Debug|Any CPU.ActiveCfg = Debug|Any CPU
{FF1F72D6-9524-4422-9497-3CC0002216ED}.Debug|Any CPU.Build.0 = Debug|Any CPU
+ {FF1F72D6-9524-4422-9497-3CC0002216ED}.Debug|Any CPU.Deploy.0 = Debug|Any CPU
{FF1F72D6-9524-4422-9497-3CC0002216ED}.Debug|ARM.ActiveCfg = Debug|ARM
{FF1F72D6-9524-4422-9497-3CC0002216ED}.Debug|ARM.Build.0 = Debug|ARM
{FF1F72D6-9524-4422-9497-3CC0002216ED}.Debug|ARM.Deploy.0 = Debug|ARM
diff --git a/README.md b/README.md
index 52735cae..d50f51c2 100644
--- a/README.md
+++ b/README.md
@@ -18,7 +18,7 @@ MQTTnet is a high performance .NET library for MQTT based communication. It prov
* TLS 1.2 support for client and server (but not UWP servers)
* Extensible communication channels (i.e. In-Memory, TCP, TCP+TLS, WS)
* Lightweight (only the low level implementation of MQTT, no overhead)
-* Performance optimized (processing ~60.000 messages / second)*
+* Performance optimized (processing ~70.000 messages / second)*
* Interfaces included for mocking and testing
* Access to internal trace messages
* Unit tested (~90 tests)
@@ -50,14 +50,15 @@ MQTTnet is a high performance .NET library for MQTT based communication. It prov
* .NET Standard 1.3+
* .NET Core 1.1+
* .NET Core App 1.1+
-* Universal Windows Platform (UWP) 10.0.10240+ (x86, x64, ARM, AnyCPU, Windows 10 IoT Core)
* .NET Framework 4.5.2+ (x86, x64, AnyCPU)
* Mono 5.2+
+* Universal Windows Platform (UWP) 10.0.10240+ (x86, x64, ARM, AnyCPU, Windows 10 IoT Core)
* Xamarin.Android 7.5+
* Xamarin.iOS 10.14+
## Supported MQTT versions
+* 5.0.0 (planned)
* 3.1.1
* 3.1.0
@@ -79,8 +80,7 @@ This library is used in the following projects:
* MQTT Client Rx (Wrapper for Reactive Extensions, )
* MQTT Tester (MQTT client test app for [Android](https://play.google.com/store/apps/details?id=com.liveowl.mqtttester) and [iOS](https://itunes.apple.com/us/app/mqtt-tester/id1278621826?mt=8))
-* Wirehome (Open Source Home Automation system for .NET, )
-
+* HA4IoT (Open Source Home Automation system for .NET, )
If you use this library and want to see your project here please let me know.
diff --git a/Source/MQTTnet.AspnetCore/Client/MqttClientConnectionContextFactory.cs b/Source/MQTTnet.AspnetCore/Client/MqttClientConnectionContextFactory.cs
new file mode 100644
index 00000000..e308ccd4
--- /dev/null
+++ b/Source/MQTTnet.AspnetCore/Client/MqttClientConnectionContextFactory.cs
@@ -0,0 +1,34 @@
+using System;
+using System.Net;
+using MQTTnet.Adapter;
+using MQTTnet.AspNetCore.Client.Tcp;
+using MQTTnet.Client;
+using MQTTnet.Diagnostics;
+using MQTTnet.Serializer;
+
+namespace MQTTnet.AspNetCore.Client
+{
+ public class MqttClientConnectionContextFactory : IMqttClientAdapterFactory
+ {
+ public IMqttChannelAdapter CreateClientAdapter(IMqttClientOptions options, IMqttNetChildLogger logger)
+ {
+ if (options == null) throw new ArgumentNullException(nameof(options));
+
+ var serializer = new MqttPacketSerializer { ProtocolVersion = options.ProtocolVersion };
+
+ switch (options.ChannelOptions)
+ {
+ case MqttClientTcpOptions tcpOptions:
+ {
+ var endpoint = new DnsEndPoint(tcpOptions.Server, tcpOptions.GetPort());
+ var tcpConnection = new TcpConnection(endpoint);
+ return new MqttConnectionContext(serializer, tcpConnection);
+ }
+ default:
+ {
+ throw new NotSupportedException();
+ }
+ }
+ }
+ }
+}
diff --git a/Tests/MQTTnet.Benchmarks/Tcp/BufferExtensions.cs b/Source/MQTTnet.AspnetCore/Client/Tcp/BufferExtensions.cs
similarity index 93%
rename from Tests/MQTTnet.Benchmarks/Tcp/BufferExtensions.cs
rename to Source/MQTTnet.AspnetCore/Client/Tcp/BufferExtensions.cs
index 879306c1..5911a3a1 100644
--- a/Tests/MQTTnet.Benchmarks/Tcp/BufferExtensions.cs
+++ b/Source/MQTTnet.AspnetCore/Client/Tcp/BufferExtensions.cs
@@ -1,7 +1,7 @@
using System;
using System.Runtime.InteropServices;
-namespace MQTTnet.Benchmarks.Tcp
+namespace MQTTnet.AspNetCore.Client.Tcp
{
public static class BufferExtensions
{
diff --git a/Tests/MQTTnet.Benchmarks/Tcp/DuplexPipe.cs b/Source/MQTTnet.AspnetCore/Client/Tcp/DuplexPipe.cs
similarity index 96%
rename from Tests/MQTTnet.Benchmarks/Tcp/DuplexPipe.cs
rename to Source/MQTTnet.AspnetCore/Client/Tcp/DuplexPipe.cs
index f5f3316d..e234da55 100644
--- a/Tests/MQTTnet.Benchmarks/Tcp/DuplexPipe.cs
+++ b/Source/MQTTnet.AspnetCore/Client/Tcp/DuplexPipe.cs
@@ -1,6 +1,6 @@
using System.IO.Pipelines;
-namespace MQTTnet.Benchmarks.Tcp
+namespace MQTTnet.AspNetCore.Client.Tcp
{
public class DuplexPipe : IDuplexPipe
{
diff --git a/Tests/MQTTnet.Benchmarks/Tcp/SocketAwaitable.cs b/Source/MQTTnet.AspnetCore/Client/Tcp/SocketAwaitable.cs
similarity index 97%
rename from Tests/MQTTnet.Benchmarks/Tcp/SocketAwaitable.cs
rename to Source/MQTTnet.AspnetCore/Client/Tcp/SocketAwaitable.cs
index 2271bd76..dbc26120 100644
--- a/Tests/MQTTnet.Benchmarks/Tcp/SocketAwaitable.cs
+++ b/Source/MQTTnet.AspnetCore/Client/Tcp/SocketAwaitable.cs
@@ -6,7 +6,7 @@ using System.Runtime.CompilerServices;
using System.Threading;
using System.Threading.Tasks;
-namespace MQTTnet.Benchmarks.Tcp
+namespace MQTTnet.AspNetCore.Client.Tcp
{
public class SocketAwaitable : ICriticalNotifyCompletion
{
@@ -23,9 +23,10 @@ namespace MQTTnet.Benchmarks.Tcp
_ioScheduler = ioScheduler;
}
- public SocketAwaitable GetAwaiter() => this;
public bool IsCompleted => ReferenceEquals(_callback, _callbackCompleted);
+ public SocketAwaitable GetAwaiter() => this;
+
public int GetResult()
{
Debug.Assert(ReferenceEquals(_callback, _callbackCompleted));
diff --git a/Tests/MQTTnet.Benchmarks/Tcp/SocketReceiver.cs b/Source/MQTTnet.AspnetCore/Client/Tcp/SocketReceiver.cs
similarity index 96%
rename from Tests/MQTTnet.Benchmarks/Tcp/SocketReceiver.cs
rename to Source/MQTTnet.AspnetCore/Client/Tcp/SocketReceiver.cs
index bc8e5c03..7d11fa2b 100644
--- a/Tests/MQTTnet.Benchmarks/Tcp/SocketReceiver.cs
+++ b/Source/MQTTnet.AspnetCore/Client/Tcp/SocketReceiver.cs
@@ -2,7 +2,7 @@
using System.IO.Pipelines;
using System.Net.Sockets;
-namespace MQTTnet.Benchmarks.Tcp
+namespace MQTTnet.AspNetCore.Client.Tcp
{
public class SocketReceiver
{
@@ -24,7 +24,6 @@ namespace MQTTnet.Benchmarks.Tcp
_eventArgs.SetBuffer(buffer);
#else
var segment = buffer.GetArray();
-
_eventArgs.SetBuffer(segment.Array, segment.Offset, segment.Count);
#endif
if (!_socket.ReceiveAsync(_eventArgs))
diff --git a/Tests/MQTTnet.Benchmarks/Tcp/SocketSender.cs b/Source/MQTTnet.AspnetCore/Client/Tcp/SocketSender.cs
similarity index 98%
rename from Tests/MQTTnet.Benchmarks/Tcp/SocketSender.cs
rename to Source/MQTTnet.AspnetCore/Client/Tcp/SocketSender.cs
index 7cb1bc1d..55192d6c 100644
--- a/Tests/MQTTnet.Benchmarks/Tcp/SocketSender.cs
+++ b/Source/MQTTnet.AspnetCore/Client/Tcp/SocketSender.cs
@@ -5,7 +5,7 @@ using System.Diagnostics;
using System.IO.Pipelines;
using System.Net.Sockets;
-namespace MQTTnet.Benchmarks.Tcp
+namespace MQTTnet.AspNetCore.Client.Tcp
{
public class SocketSender
{
@@ -61,7 +61,6 @@ namespace MQTTnet.Benchmarks.Tcp
_eventArgs.SetBuffer(MemoryMarshal.AsMemory(memory));
#else
var segment = memory.GetArray();
-
_eventArgs.SetBuffer(segment.Array, segment.Offset, segment.Count);
#endif
if (!_socket.SendAsync(_eventArgs))
diff --git a/Tests/MQTTnet.Benchmarks/Tcp/TcpConnection.cs b/Source/MQTTnet.AspnetCore/Client/Tcp/TcpConnection.cs
similarity index 81%
rename from Tests/MQTTnet.Benchmarks/Tcp/TcpConnection.cs
rename to Source/MQTTnet.AspnetCore/Client/Tcp/TcpConnection.cs
index 83cb98a8..37913fe4 100644
--- a/Tests/MQTTnet.Benchmarks/Tcp/TcpConnection.cs
+++ b/Source/MQTTnet.AspnetCore/Client/Tcp/TcpConnection.cs
@@ -1,30 +1,35 @@
using System;
+using System.Collections.Generic;
using System.IO;
using System.IO.Pipelines;
using System.Net;
using System.Net.Sockets;
using System.Threading.Tasks;
+using Microsoft.AspNetCore.Connections;
+using Microsoft.AspNetCore.Http.Features;
using MQTTnet.Exceptions;
-namespace MQTTnet.Benchmarks.Tcp
+namespace MQTTnet.AspNetCore.Client.Tcp
{
- public class TcpConnection
+ public class TcpConnection : ConnectionContext
{
- private readonly Socket _socket;
private volatile bool _aborted;
private readonly EndPoint _endPoint;
+ private SocketSender _sender;
+ private SocketReceiver _receiver;
+
+ private Socket _socket;
private IDuplexPipe _application;
- private IDuplexPipe _transport;
- private readonly SocketSender _sender;
- private readonly SocketReceiver _receiver;
+
+ public bool IsConnected { get; private set; }
+ public override string ConnectionId { get; set; }
+ public override IFeatureCollection Features { get; }
+ public override IDictionary