diff --git a/.gitignore b/.gitignore index de42c58..45c63dd 100644 --- a/.gitignore +++ b/.gitignore @@ -1,5 +1,7 @@ ## Ignore Visual Studio temporary files, build results, and ## files generated by popular Visual Studio add-ons. +## +## Get latest from https://github.com/github/gitignore/blob/master/VisualStudio.gitignore # User-specific files *.suo @@ -15,12 +17,12 @@ [Dd]ebugPublic/ [Rr]elease/ [Rr]eleases/ -[Xx]64/ -[Xx]86/ -[Bb]uild/ +x64/ +x86/ bld/ [Bb]in/ [Oo]bj/ +[Ll]og/ # Visual Studio 2015 cache/options directory .vs/ @@ -40,9 +42,11 @@ TestResult.xml [Rr]eleasePS/ dlldata.c -# DNX +# .NET Core project.lock.json +project.fragment.lock.json artifacts/ +**/Properties/launchSettings.json *_i.c *_p.c @@ -81,6 +85,7 @@ ipch/ *.sdf *.cachefile *.VC.db +*.VC.VC.opendb # Visual Studio profiler *.psess @@ -108,6 +113,10 @@ _TeamCity* # DotCover is a Code Coverage Tool *.dotCover +# Visual Studio code coverage results +*.coverage +*.coveragexml + # NCrunch _NCrunch_* .*crunch*.local.xml @@ -139,13 +148,16 @@ publish/ # Publish Web Output *.[Pp]ublish.xml *.azurePubxml - -# TODO: Un-comment the next line if you do not want to checkin -# your web deploy settings because they may include unencrypted -# passwords -#*.pubxml +# TODO: Comment the next line if you want to checkin your web deploy settings +# but database connection strings (with potential passwords) will be unencrypted +*.pubxml *.publishproj +# Microsoft Azure Web App publish settings. Comment the next line if you want to +# checkin your Azure Web App publish settings, but sensitive information contained +# in these scripts will be unencrypted +PublishScripts/ + # NuGet Packages *.nupkg # The packages folder can be ignored because of Package Restore @@ -154,7 +166,7 @@ publish/ !**/packages/build/ # Uncomment if necessary however generally it will be regenerated when needed #!**/packages/repositories.config -# NuGet v3's project.json files produces more ignoreable files +# NuGet v3's project.json files produces more ignorable files *.nuget.props *.nuget.targets @@ -166,12 +178,11 @@ csx/ ecf/ rcf/ -# Microsoft Azure ApplicationInsights config file -ApplicationInsights.config - -# Windows Store app package directory +# Windows Store app package directories and files AppPackages/ BundleArtifacts/ +Package.StoreAssociation.xml +_pkginfo.txt # Visual Studio cache files # files ending in .cache can be ignored @@ -181,16 +192,19 @@ BundleArtifacts/ # Others ClientBin/ -[Ss]tyle[Cc]op.* ~$* *~ *.dbmdl *.dbproj.schemaview +*.jfm *.pfx *.publishsettings -node_modules/ orleans.codegen.cs +# Since there are multiple workflows, uncomment next line to ignore bower_components +# (https://github.com/github/gitignore/pull/1529#issuecomment-104372622) +#bower_components/ + # RIA/Silverlight projects Generated_Code/ @@ -205,6 +219,7 @@ UpgradeLog*.htm # SQL Server files *.mdf *.ldf +*.ndf # Business Intelligence projects *.rdl.data @@ -219,6 +234,10 @@ FakesAssemblies/ # Node.js Tools for Visual Studio .ntvs_analysis.dat +node_modules/ + +# Typescript v1 declaration files +typings/ # Visual Studio 6 build log *.plg @@ -226,6 +245,9 @@ FakesAssemblies/ # Visual Studio 6 workspace options file *.opt +# Visual Studio 6 auto-generated workspace file (contains which files were open etc.) +*.vbw + # Visual Studio LightSwitch build output **/*.HTMLClient/GeneratedArtifacts **/*.DesktopClient/GeneratedArtifacts @@ -234,13 +256,34 @@ FakesAssemblies/ **/*.Server/ModelManifest.xml _Pvt_Extensions -# LightSwitch generated files -GeneratedArtifacts/ -ModelManifest.xml - # Paket dependency manager .paket/paket.exe +paket-files/ # FAKE - F# Make .fake/ -nuget.exe \ No newline at end of file + +# JetBrains Rider +.idea/ +*.sln.iml + +# CodeRush +.cr/ + +# Python Tools for Visual Studio (PTVS) +__pycache__/ +*.pyc + +# Cake - Uncomment if you are using it +# tools/** +# !tools/packages.config + +# Telerik's JustMock configuration file +*.jmconfig + +# BizTalk build output +*.btp.cs +*.btm.cs +*.odx.cs +*.xsd.cs +Build/nuget.exe diff --git a/Build/MQTTnet.nuspec b/Build/MQTTnet.nuspec new file mode 100644 index 0000000..2211891 --- /dev/null +++ b/Build/MQTTnet.nuspec @@ -0,0 +1,47 @@ + + + + MQTTnet + 2.1.4 + Christian Kratky + Christian Kratky + https://github.com/chkr1011/MQTTnet/blob/master/LICENSE + https://github.com/chkr1011/MQTTnet + https://raw.githubusercontent.com/chkr1011/MQTTnet/master/Images/Logo_128x128.png + false + MQTTnet is a .NET library for MQTT based communication. It provides a MQTT client and a MQTT server (broker). + * [.NET Standard] Added support for .NET Standard 1.3 (Thanks to 1iveowl) +* [Server] Added an even which allows processing of all received messages from the clients +* [Server] Fixed an issue when stopping the server + + Copyright Christian Kratky 2016-2017 + MQTT MQTTClient MQTTServer MQTTBroker Broker + + + + + + + + + + + + + + + + + + + + + + + + + + + + + \ No newline at end of file diff --git a/Build/build.ps1 b/Build/build.ps1 new file mode 100644 index 0000000..b8e71b1 --- /dev/null +++ b/Build/build.ps1 @@ -0,0 +1,12 @@ +param([string]$version) + +if ([string]::IsNullOrEmpty($version)) {$version = "0.0.1"} + +$msbuild = "MSBuild.exe" +&$msbuild ..\Frameworks\MQTTnet.NetFramework\MQTTnet.NetFramework.csproj /t:Build /p:Configuration="Release" +&$msbuild ..\Frameworks\MQTTnet.Netstandard\MQTTnet.Netstandard.csproj /t:Build /p:Configuration="Release" +&$msbuild ..\Frameworks\MQTTnet.UniversalWindows\MQTTnet.UniversalWindows.csproj /t:Build /p:Configuration="Release" + +Remove-Item .\NuGet -Force -Recurse +New-Item -ItemType Directory -Force -Path .\NuGet +.\NuGet.exe pack MQTTnet.nuspec -Verbosity detailed -Symbols -OutputDir "NuGet" -Version $version \ No newline at end of file diff --git a/Frameworks/MQTTnet.NetCoreApp/MQTTnet.NetCoreApp.csproj b/Frameworks/MQTTnet.NetCoreApp/MQTTnet.NetCoreApp.csproj deleted file mode 100644 index ec45201..0000000 --- a/Frameworks/MQTTnet.NetCoreApp/MQTTnet.NetCoreApp.csproj +++ /dev/null @@ -1,34 +0,0 @@ - - - - netcoreapp1.1 - Christian Kratky - Christian Kratky - MQTTnet - MQTTnet is a .NET library for MQTT based communication. It provides a MQTT client and a MQTT server (broker). - Copyright © Christian Kratky 2016-2017 - 2.1.1.0 - 2.1.1.0 - 2.1.1.0 - False - MQTTnet - MQTTnet - MQTTnet.NetCore - https://github.com/chkr1011/MQTTnet - https://github.com/chkr1011/MQTTnet - MQTT MQTTClient MQTTServer MQTTBroker Broker - https://raw.githubusercontent.com/chkr1011/MQTTnet/master/Images/Logo_128x128.png - https://github.com/chkr1011/MQTTnet/blob/master/LICENSE - - - - - - - - - - - - - \ No newline at end of file diff --git a/Frameworks/MQTTnet.NetFramework/Implementations/MqttServerAdapter.cs b/Frameworks/MQTTnet.NetFramework/Implementations/MqttServerAdapter.cs index f739756..cbfcf66 100644 --- a/Frameworks/MQTTnet.NetFramework/Implementations/MqttServerAdapter.cs +++ b/Frameworks/MQTTnet.NetFramework/Implementations/MqttServerAdapter.cs @@ -63,6 +63,7 @@ namespace MQTTnet.Implementations { _isRunning = false; + _cancellationTokenSource?.Cancel(false); _cancellationTokenSource?.Dispose(); _cancellationTokenSource = null; @@ -88,7 +89,7 @@ namespace MQTTnet.Implementations var clientAdapter = new MqttChannelCommunicationAdapter(new MqttTcpChannel(clientSocket, null), new DefaultMqttV311PacketSerializer()); ClientConnected?.Invoke(this, new MqttClientConnectedEventArgs(clientSocket.RemoteEndPoint.ToString(), clientAdapter)); } - catch (Exception exception) + catch (Exception exception) when (!(exception is ObjectDisposedException)) { MqttTrace.Error(nameof(MqttServerAdapter), exception, "Error while acceping connection at default endpoint."); } diff --git a/Frameworks/MQTTnet.NetFramework/Properties/AssemblyInfo.cs b/Frameworks/MQTTnet.NetFramework/Properties/AssemblyInfo.cs index 24471d2..4d0a57f 100644 --- a/Frameworks/MQTTnet.NetFramework/Properties/AssemblyInfo.cs +++ b/Frameworks/MQTTnet.NetFramework/Properties/AssemblyInfo.cs @@ -11,5 +11,5 @@ using System.Runtime.InteropServices; [assembly: AssemblyCulture("")] [assembly: ComVisible(false)] [assembly: Guid("a480ef90-0eaa-4d9a-b271-47a9c47f6f7d")] -[assembly: AssemblyVersion("2.1.1.0")] -[assembly: AssemblyFileVersion("2.1.1.0")] \ No newline at end of file +[assembly: AssemblyVersion("2.1.4.0")] +[assembly: AssemblyFileVersion("2.1.4.0")] \ No newline at end of file diff --git a/Frameworks/MQTTnet.NetCoreApp/Implementations/MqttServerAdapter.cs b/Frameworks/MQTTnet.NetStandard/Implementations/MqttServerAdapter.cs similarity index 98% rename from Frameworks/MQTTnet.NetCoreApp/Implementations/MqttServerAdapter.cs rename to Frameworks/MQTTnet.NetStandard/Implementations/MqttServerAdapter.cs index 0203134..863d3e7 100644 --- a/Frameworks/MQTTnet.NetCoreApp/Implementations/MqttServerAdapter.cs +++ b/Frameworks/MQTTnet.NetStandard/Implementations/MqttServerAdapter.cs @@ -61,6 +61,7 @@ namespace MQTTnet.Implementations { _isRunning = false; + _cancellationTokenSource?.Cancel(false); _cancellationTokenSource?.Dispose(); _cancellationTokenSource = null; diff --git a/Frameworks/MQTTnet.NetCoreApp/Implementations/MqttTcpChannel.cs b/Frameworks/MQTTnet.NetStandard/Implementations/MqttTcpChannel.cs similarity index 100% rename from Frameworks/MQTTnet.NetCoreApp/Implementations/MqttTcpChannel.cs rename to Frameworks/MQTTnet.NetStandard/Implementations/MqttTcpChannel.cs diff --git a/Frameworks/MQTTnet.NetStandard/MQTTnet.Netstandard.csproj b/Frameworks/MQTTnet.NetStandard/MQTTnet.Netstandard.csproj new file mode 100644 index 0000000..2a60e55 --- /dev/null +++ b/Frameworks/MQTTnet.NetStandard/MQTTnet.Netstandard.csproj @@ -0,0 +1,29 @@ + + + + netstandard1.3 + MQTTnet + MQTTnet + 2.1.4.0 + 2.1.4.0 + 0.0.0.0 + + + + + + + + + + + + + + + + + + + + \ No newline at end of file diff --git a/Frameworks/MQTTnet.NetCoreApp/MqttClientFactory.cs b/Frameworks/MQTTnet.NetStandard/MqttClientFactory.cs similarity index 100% rename from Frameworks/MQTTnet.NetCoreApp/MqttClientFactory.cs rename to Frameworks/MQTTnet.NetStandard/MqttClientFactory.cs diff --git a/Frameworks/MQTTnet.NetCoreApp/MqttServerFactory.cs b/Frameworks/MQTTnet.NetStandard/MqttServerFactory.cs similarity index 100% rename from Frameworks/MQTTnet.NetCoreApp/MqttServerFactory.cs rename to Frameworks/MQTTnet.NetStandard/MqttServerFactory.cs diff --git a/Frameworks/MQTTnet.UniversalWindows/MQTTnet.UniversalWindows.csproj b/Frameworks/MQTTnet.UniversalWindows/MQTTnet.UniversalWindows.csproj index fa6f897..791ee28 100644 --- a/Frameworks/MQTTnet.UniversalWindows/MQTTnet.UniversalWindows.csproj +++ b/Frameworks/MQTTnet.UniversalWindows/MQTTnet.UniversalWindows.csproj @@ -11,11 +11,12 @@ MQTTnet en-US UAP - 10.0.14393.0 + 10.0.15063.0 10.0.10240.0 14 512 {A5A43C5B-DE2A-4C0C-9213-0A381AF9435A};{FAE04EC0-301F-11D3-BF4B-00C04F79EFBC} + win10-arm;win10-arm-aot;win10-x86;win10-x86-aot;win10-x64;win10-x64-aot AnyCPU @@ -108,10 +109,6 @@ false bin\x64\Release\MQTTnet.XML - - - - @@ -126,6 +123,11 @@ MQTTnet.Core + + + 5.3.3 + + 14.0 diff --git a/Frameworks/MQTTnet.UniversalWindows/Properties/AssemblyInfo.cs b/Frameworks/MQTTnet.UniversalWindows/Properties/AssemblyInfo.cs index 7ad7d87..dee61f7 100644 --- a/Frameworks/MQTTnet.UniversalWindows/Properties/AssemblyInfo.cs +++ b/Frameworks/MQTTnet.UniversalWindows/Properties/AssemblyInfo.cs @@ -10,5 +10,5 @@ using System.Runtime.InteropServices; [assembly: AssemblyTrademark("")] [assembly: AssemblyCulture("")] [assembly: ComVisible(false)] -[assembly: AssemblyVersion("2.1.1.0")] -[assembly: AssemblyFileVersion("2.1.1.0")] \ No newline at end of file +[assembly: AssemblyVersion("2.1.4.0")] +[assembly: AssemblyFileVersion("2.1.4.0")] \ No newline at end of file diff --git a/Frameworks/MQTTnet.UniversalWindows/project.json b/Frameworks/MQTTnet.UniversalWindows/project.json deleted file mode 100644 index 239b57e..0000000 --- a/Frameworks/MQTTnet.UniversalWindows/project.json +++ /dev/null @@ -1,17 +0,0 @@ -{ - "dependencies": { - "Microsoft.NETCore.UniversalWindowsPlatform": "5.1.0" - }, - "frameworks": { - "uap10.0": {} - }, - "runtimes": { - "win10": {}, - "win10-arm": {}, - "win10-arm-aot": {}, - "win10-x86": {}, - "win10-x86-aot": {}, - "win10-x64": {}, - "win10-x64-aot": {} - } -} \ No newline at end of file diff --git a/MQTTnet.Core/MqttApplicationMessageReceivedEventArgs.cs b/MQTTnet.Core/Client/MqttApplicationMessageReceivedEventArgs.cs similarity index 93% rename from MQTTnet.Core/MqttApplicationMessageReceivedEventArgs.cs rename to MQTTnet.Core/Client/MqttApplicationMessageReceivedEventArgs.cs index c624bea..9e12028 100644 --- a/MQTTnet.Core/MqttApplicationMessageReceivedEventArgs.cs +++ b/MQTTnet.Core/Client/MqttApplicationMessageReceivedEventArgs.cs @@ -1,6 +1,6 @@ using System; -namespace MQTTnet.Core +namespace MQTTnet.Core.Client { public sealed class MqttApplicationMessageReceivedEventArgs : EventArgs { diff --git a/MQTTnet.Core/Client/MqttClient.cs b/MQTTnet.Core/Client/MqttClient.cs index cc3ebee..df3c61f 100644 --- a/MQTTnet.Core/Client/MqttClient.cs +++ b/MQTTnet.Core/Client/MqttClient.cs @@ -185,7 +185,10 @@ namespace MQTTnet.Core.Client } finally { - _cancellationTokenSource?.Cancel(); + _cancellationTokenSource?.Cancel(false); + _cancellationTokenSource?.Dispose(); + _cancellationTokenSource = null; + IsConnected = false; Disconnected?.Invoke(this, EventArgs.Empty); } @@ -234,13 +237,7 @@ namespace MQTTnet.Core.Client _processedPublishPackets.Add(publishPacket.PacketIdentifier); } - var applicationMessage = new MqttApplicationMessage( - publishPacket.Topic, - publishPacket.Payload, - publishPacket.QualityOfServiceLevel, - publishPacket.Retain - ); - + var applicationMessage = publishPacket.ToApplicationMessage(); ApplicationMessageReceived?.Invoke(this, new MqttApplicationMessageReceivedEventArgs(applicationMessage)); } diff --git a/MQTTnet.Core/Internal/MqttApplicationMessageExtensions.cs b/MQTTnet.Core/Internal/MqttApplicationMessageExtensions.cs index 71cdb7f..7d3c665 100644 --- a/MQTTnet.Core/Internal/MqttApplicationMessageExtensions.cs +++ b/MQTTnet.Core/Internal/MqttApplicationMessageExtensions.cs @@ -4,6 +4,16 @@ namespace MQTTnet.Core.Internal { internal static class MqttApplicationMessageExtensions { + public static MqttApplicationMessage ToApplicationMessage(this MqttPublishPacket publishPacket) + { + return new MqttApplicationMessage( + publishPacket.Topic, + publishPacket.Payload, + publishPacket.QualityOfServiceLevel, + publishPacket.Retain + ); + } + public static MqttPublishPacket ToPublishPacket(this MqttApplicationMessage applicationMessage) { if (applicationMessage == null) diff --git a/MQTTnet.Core/MQTTnet.Core.csproj b/MQTTnet.Core/MQTTnet.Core.csproj index 1b8346d..4d12864 100644 --- a/MQTTnet.Core/MQTTnet.Core.csproj +++ b/MQTTnet.Core/MQTTnet.Core.csproj @@ -5,20 +5,20 @@ MQTTnet.Core MQTTnet.Core False - MQTTnet is a .NET library for MQTT based communication. It provides a MQTT client and a MQTT server (broker). - MQTTnet - Christian Kratky - Christian Kratky - 2.1.2.0 - MQTTnet.Core - Copyright © Christian Kratky 2016-2017 - https://github.com/chkr1011/MQTTnet - https://raw.githubusercontent.com/chkr1011/MQTTnet/master/Images/Logo_128x128.png - https://github.com/chkr1011/MQTTnet - MQTT MQTTClient MQTTServer MQTTBroker Broker - 2.1.2.0 - 2.1.2.0 - https://github.com/chkr1011/MQTTnet/blob/master/LICENSE + + + + + 0.0.0.0 + + + + + + + 2.1.4.0 + 2.1.4.0 + diff --git a/MQTTnet.Core/Server/MqttApplicationMessageReceivedEventArgs.cs b/MQTTnet.Core/Server/MqttApplicationMessageReceivedEventArgs.cs new file mode 100644 index 0000000..4f2cc80 --- /dev/null +++ b/MQTTnet.Core/Server/MqttApplicationMessageReceivedEventArgs.cs @@ -0,0 +1,17 @@ +using System; + +namespace MQTTnet.Core.Server +{ + public sealed class MqttApplicationMessageReceivedEventArgs : EventArgs + { + public MqttApplicationMessageReceivedEventArgs(string clientId, MqttApplicationMessage applicationMessage) + { + ClientId = clientId; + ApplicationMessage = applicationMessage ?? throw new ArgumentNullException(nameof(applicationMessage)); + } + + public string ClientId { get; } + + public MqttApplicationMessage ApplicationMessage { get; } + } +} diff --git a/MQTTnet.Core/Server/MqttClientSession.cs b/MQTTnet.Core/Server/MqttClientSession.cs index 19b4cfd..b89e73e 100644 --- a/MQTTnet.Core/Server/MqttClientSession.cs +++ b/MQTTnet.Core/Server/MqttClientSession.cs @@ -19,20 +19,23 @@ namespace MQTTnet.Core.Server private readonly MqttClientMessageQueue _messageQueue; private readonly Action _publishPacketReceivedCallback; private readonly MqttServerOptions _options; - + private CancellationTokenSource _cancellationTokenSource; private IMqttCommunicationAdapter _adapter; private string _identifier; private MqttApplicationMessage _willApplicationMessage; - public MqttClientSession(MqttServerOptions options, Action publishPacketReceivedCallback) + public MqttClientSession(string clientId, MqttServerOptions options, Action publishPacketReceivedCallback) { + ClientId = clientId; _options = options ?? throw new ArgumentNullException(nameof(options)); _publishPacketReceivedCallback = publishPacketReceivedCallback ?? throw new ArgumentNullException(nameof(publishPacketReceivedCallback)); _messageQueue = new MqttClientMessageQueue(options); } + public string ClientId { get; } + public bool IsConnected => _adapter != null; public async Task RunAsync(string identifier, MqttApplicationMessage willApplicationMessage, IMqttCommunicationAdapter adapter) diff --git a/MQTTnet.Core/Server/MqttClientSessionsManager.cs b/MQTTnet.Core/Server/MqttClientSessionsManager.cs index 2a9a0b2..ae4d865 100644 --- a/MQTTnet.Core/Server/MqttClientSessionsManager.cs +++ b/MQTTnet.Core/Server/MqttClientSessionsManager.cs @@ -5,6 +5,7 @@ using System.Threading.Tasks; using MQTTnet.Core.Adapter; using MQTTnet.Core.Diagnostics; using MQTTnet.Core.Exceptions; +using MQTTnet.Core.Internal; using MQTTnet.Core.Packets; using MQTTnet.Core.Protocol; @@ -21,6 +22,8 @@ namespace MQTTnet.Core.Server _options = options ?? throw new ArgumentNullException(nameof(options)); } + public event EventHandler ApplicationMessageReceived; + public async Task RunClientSessionAsync(MqttClientConnectedEventArgs eventArgs) { try @@ -114,7 +117,7 @@ namespace MQTTnet.Core.Server { isExistingSession = false; - clientSession = new MqttClientSession(_options, DispatchPublishPacket); + clientSession = new MqttClientSession(connectPacket.ClientId, _options, DispatchPublishPacket); _clientSessions[connectPacket.ClientId] = clientSession; MqttTrace.Verbose(nameof(MqttClientSessionsManager), $"Created a new session for client '{connectPacket.ClientId}'."); @@ -126,6 +129,9 @@ namespace MQTTnet.Core.Server private void DispatchPublishPacket(MqttClientSession senderClientSession, MqttPublishPacket publishPacket) { + var eventArgs = new MqttApplicationMessageReceivedEventArgs(senderClientSession.ClientId, publishPacket.ToApplicationMessage()); + ApplicationMessageReceived?.Invoke(this, eventArgs); + foreach (var clientSession in _clientSessions.Values.ToList()) { clientSession.EnqueuePublishPacket(senderClientSession, publishPacket); diff --git a/MQTTnet.Core/Server/MqttServer.cs b/MQTTnet.Core/Server/MqttServer.cs index e1cda96..ca55d7a 100644 --- a/MQTTnet.Core/Server/MqttServer.cs +++ b/MQTTnet.Core/Server/MqttServer.cs @@ -21,6 +21,7 @@ namespace MQTTnet.Core.Server _adapters = adapters ?? throw new ArgumentNullException(nameof(adapters)); _clientSessionsManager = new MqttClientSessionsManager(options); + _clientSessionsManager.ApplicationMessageReceived += (s, e) => ApplicationMessageReceived?.Invoke(s, e); } public IList GetConnectedClients() @@ -30,6 +31,8 @@ namespace MQTTnet.Core.Server public event EventHandler ClientConnected; + public event EventHandler ApplicationMessageReceived; + public void InjectClient(string identifier, IMqttCommunicationAdapter adapter) { if (adapter == null) throw new ArgumentNullException(nameof(adapter)); @@ -56,7 +59,8 @@ namespace MQTTnet.Core.Server public void Stop() { - _cancellationTokenSource?.Cancel(); + _cancellationTokenSource?.Cancel(false); + _cancellationTokenSource?.Dispose(); _cancellationTokenSource = null; foreach (var adapter in _adapters) diff --git a/MQTTnet.nuspec b/MQTTnet.nuspec deleted file mode 100644 index ab1869b..0000000 --- a/MQTTnet.nuspec +++ /dev/null @@ -1,56 +0,0 @@ - - - - MQTTnet - 2.1.3.0 - Christian Kratky - Christian Kratky - https://github.com/chkr1011/MQTTnet/blob/master/LICENSE - https://github.com/chkr1011/MQTTnet - https://raw.githubusercontent.com/chkr1011/MQTTnet/master/Images/Logo_128x128.png - false - MQTTnet is a .NET library for MQTT based communication. It provides a MQTT client and a MQTT server (broker). - * [Core] Any exception while accessing the underlying data source is now rethrown as "MqttCommunicationException". -* [Core] Extended exception information when an invalid packet type is received. -* [Server] Added TLS 1.2 support (but not for UWP) (thanks to Zazzmatazz) -* [Client] Added TLS 1.2 support (thanks to Zazzmatazz) -* [Core] Optimized async task management -* [Nuget] Fixed x64 files - Copyright Christian Kratky 2016-2017 - MQTT MQTTClient MQTTServer MQTTBroker Broker - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - \ No newline at end of file diff --git a/MQTTnet.sln b/MQTTnet.sln index 8b8d283..697f504 100644 --- a/MQTTnet.sln +++ b/MQTTnet.sln @@ -1,7 +1,7 @@  Microsoft Visual Studio Solution File, Format Version 12.00 # Visual Studio 15 -VisualStudioVersion = 15.0.26430.12 +VisualStudioVersion = 15.0.26430.15 MinimumVisualStudioVersion = 10.0.40219.1 Project("{FAE04EC0-301F-11D3-BF4B-00C04F79EFBC}") = "MQTTnet.Core.Tests", "Tests\MQTTnet.Core.Tests\MQTTnet.Core.Tests.csproj", "{A7FF0C91-25DE-4BA6-B39E-F54E8DADF1CC}" EndProject @@ -13,19 +13,20 @@ Project("{2150E333-8FDC-42A3-9474-1A3956D46DE8}") = "Tests", "Tests", "{9248C2E1 EndProject Project("{2150E333-8FDC-42A3-9474-1A3956D46DE8}") = "Frameworks", "Frameworks", "{32A630A7-2598-41D7-B625-204CD906F5FB}" EndProject -Project("{FAE04EC0-301F-11D3-BF4B-00C04F79EFBC}") = "MQTTnet.Core", "MQTTnet.Core\MQTTnet.Core.csproj", "{2ECB99E4-72D0-4C23-99BA-93D511D3967D}" -EndProject -Project("{2150E333-8FDC-42A3-9474-1A3956D46DE8}") = "Solution Items", "Solution Items", "{002203AF-2565-4C0D-95ED-027FDEFE0C35}" - ProjectSection(SolutionItems) = preProject - MQTTnet.nuspec = MQTTnet.nuspec - EndProjectSection -EndProject -Project("{9A19103F-16F7-4668-BE54-9A1E7A4F7556}") = "MQTTnet.NetCoreApp", "Frameworks\MQTTnet.NetCoreApp\MQTTnet.NetCoreApp.csproj", "{1A1B7F51-5328-4395-9D9C-07D70965825E}" +Project("{9A19103F-16F7-4668-BE54-9A1E7A4F7556}") = "MQTTnet.Core", "MQTTnet.Core\MQTTnet.Core.csproj", "{2ECB99E4-72D0-4C23-99BA-93D511D3967D}" EndProject Project("{FAE04EC0-301F-11D3-BF4B-00C04F79EFBC}") = "MQTTnet.TestApp.NetFramework", "Tests\MQTTnet.TestApp.NetFramework\MQTTnet.TestApp.NetFramework.csproj", "{D9D74F33-6943-49B2-B765-7BD589082098}" EndProject Project("{FAE04EC0-301F-11D3-BF4B-00C04F79EFBC}") = "MQTTnet.TestApp.UniversalWindows", "Tests\MQTTnet.TestApp.UniversalWindows\MQTTnet.TestApp.UniversalWindows.csproj", "{FF1F72D6-9524-4422-9497-3CC0002216ED}" EndProject +Project("{9A19103F-16F7-4668-BE54-9A1E7A4F7556}") = "MQTTnet.NetStandard", "Frameworks\MQTTnet.Netstandard\MQTTnet.NetStandard.csproj", "{3587E506-55A2-4EB3-99C7-DC01E42D25D2}" +EndProject +Project("{2150E333-8FDC-42A3-9474-1A3956D46DE8}") = "Build", "Build", "{67C28AC1-BC3A-420A-BE9C-FA2401431CF9}" + ProjectSection(SolutionItems) = preProject + Build\build.ps1 = Build\build.ps1 + Build\MQTTnet.nuspec = Build\MQTTnet.nuspec + EndProjectSection +EndProject Global GlobalSection(SolutionConfigurationPlatforms) = preSolution Debug|Any CPU = Debug|Any CPU @@ -71,6 +72,7 @@ Global {A480EF90-0EAA-4D9A-B271-47A9C47F6F7D}.Release|x86.ActiveCfg = Release|x86 {A480EF90-0EAA-4D9A-B271-47A9C47F6F7D}.Release|x86.Build.0 = Release|x86 {BD60C727-D8E8-40C3-B8E3-C95A864AE611}.Debug|Any CPU.ActiveCfg = Debug|Any CPU + {BD60C727-D8E8-40C3-B8E3-C95A864AE611}.Debug|Any CPU.Build.0 = Debug|Any CPU {BD60C727-D8E8-40C3-B8E3-C95A864AE611}.Debug|ARM.ActiveCfg = Debug|ARM {BD60C727-D8E8-40C3-B8E3-C95A864AE611}.Debug|ARM.Build.0 = Debug|ARM {BD60C727-D8E8-40C3-B8E3-C95A864AE611}.Debug|x64.ActiveCfg = Debug|x64 @@ -78,6 +80,7 @@ Global {BD60C727-D8E8-40C3-B8E3-C95A864AE611}.Debug|x86.ActiveCfg = Debug|x86 {BD60C727-D8E8-40C3-B8E3-C95A864AE611}.Debug|x86.Build.0 = Debug|x86 {BD60C727-D8E8-40C3-B8E3-C95A864AE611}.Release|Any CPU.ActiveCfg = Release|Any CPU + {BD60C727-D8E8-40C3-B8E3-C95A864AE611}.Release|Any CPU.Build.0 = Release|Any CPU {BD60C727-D8E8-40C3-B8E3-C95A864AE611}.Release|ARM.ActiveCfg = Release|ARM {BD60C727-D8E8-40C3-B8E3-C95A864AE611}.Release|ARM.Build.0 = Release|ARM {BD60C727-D8E8-40C3-B8E3-C95A864AE611}.Release|x64.ActiveCfg = Release|x64 @@ -100,22 +103,6 @@ Global {2ECB99E4-72D0-4C23-99BA-93D511D3967D}.Release|x64.Build.0 = Release|x64 {2ECB99E4-72D0-4C23-99BA-93D511D3967D}.Release|x86.ActiveCfg = Release|x86 {2ECB99E4-72D0-4C23-99BA-93D511D3967D}.Release|x86.Build.0 = Release|x86 - {1A1B7F51-5328-4395-9D9C-07D70965825E}.Debug|Any CPU.ActiveCfg = Debug|Any CPU - {1A1B7F51-5328-4395-9D9C-07D70965825E}.Debug|Any CPU.Build.0 = Debug|Any CPU - {1A1B7F51-5328-4395-9D9C-07D70965825E}.Debug|ARM.ActiveCfg = Debug|Any CPU - {1A1B7F51-5328-4395-9D9C-07D70965825E}.Debug|ARM.Build.0 = Debug|Any CPU - {1A1B7F51-5328-4395-9D9C-07D70965825E}.Debug|x64.ActiveCfg = Debug|x64 - {1A1B7F51-5328-4395-9D9C-07D70965825E}.Debug|x64.Build.0 = Debug|x64 - {1A1B7F51-5328-4395-9D9C-07D70965825E}.Debug|x86.ActiveCfg = Debug|x86 - {1A1B7F51-5328-4395-9D9C-07D70965825E}.Debug|x86.Build.0 = Debug|x86 - {1A1B7F51-5328-4395-9D9C-07D70965825E}.Release|Any CPU.ActiveCfg = Release|Any CPU - {1A1B7F51-5328-4395-9D9C-07D70965825E}.Release|Any CPU.Build.0 = Release|Any CPU - {1A1B7F51-5328-4395-9D9C-07D70965825E}.Release|ARM.ActiveCfg = Release|Any CPU - {1A1B7F51-5328-4395-9D9C-07D70965825E}.Release|ARM.Build.0 = Release|Any CPU - {1A1B7F51-5328-4395-9D9C-07D70965825E}.Release|x64.ActiveCfg = Release|x64 - {1A1B7F51-5328-4395-9D9C-07D70965825E}.Release|x64.Build.0 = Release|x64 - {1A1B7F51-5328-4395-9D9C-07D70965825E}.Release|x86.ActiveCfg = Release|x86 - {1A1B7F51-5328-4395-9D9C-07D70965825E}.Release|x86.Build.0 = Release|x86 {D9D74F33-6943-49B2-B765-7BD589082098}.Debug|Any CPU.ActiveCfg = Debug|Any CPU {D9D74F33-6943-49B2-B765-7BD589082098}.Debug|Any CPU.Build.0 = Debug|Any CPU {D9D74F33-6943-49B2-B765-7BD589082098}.Debug|ARM.ActiveCfg = Debug|Any CPU @@ -133,6 +120,7 @@ Global {D9D74F33-6943-49B2-B765-7BD589082098}.Release|x86.ActiveCfg = Release|x86 {D9D74F33-6943-49B2-B765-7BD589082098}.Release|x86.Build.0 = Release|x86 {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|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 @@ -143,6 +131,7 @@ Global {FF1F72D6-9524-4422-9497-3CC0002216ED}.Debug|x86.Build.0 = Debug|x86 {FF1F72D6-9524-4422-9497-3CC0002216ED}.Debug|x86.Deploy.0 = Debug|x86 {FF1F72D6-9524-4422-9497-3CC0002216ED}.Release|Any CPU.ActiveCfg = Release|Any CPU + {FF1F72D6-9524-4422-9497-3CC0002216ED}.Release|Any CPU.Build.0 = Release|Any CPU {FF1F72D6-9524-4422-9497-3CC0002216ED}.Release|ARM.ActiveCfg = Release|ARM {FF1F72D6-9524-4422-9497-3CC0002216ED}.Release|ARM.Build.0 = Release|ARM {FF1F72D6-9524-4422-9497-3CC0002216ED}.Release|ARM.Deploy.0 = Release|ARM @@ -152,6 +141,22 @@ Global {FF1F72D6-9524-4422-9497-3CC0002216ED}.Release|x86.ActiveCfg = Release|x86 {FF1F72D6-9524-4422-9497-3CC0002216ED}.Release|x86.Build.0 = Release|x86 {FF1F72D6-9524-4422-9497-3CC0002216ED}.Release|x86.Deploy.0 = Release|x86 + {3587E506-55A2-4EB3-99C7-DC01E42D25D2}.Debug|Any CPU.ActiveCfg = Debug|Any CPU + {3587E506-55A2-4EB3-99C7-DC01E42D25D2}.Debug|Any CPU.Build.0 = Debug|Any CPU + {3587E506-55A2-4EB3-99C7-DC01E42D25D2}.Debug|ARM.ActiveCfg = Debug|Any CPU + {3587E506-55A2-4EB3-99C7-DC01E42D25D2}.Debug|ARM.Build.0 = Debug|Any CPU + {3587E506-55A2-4EB3-99C7-DC01E42D25D2}.Debug|x64.ActiveCfg = Debug|x64 + {3587E506-55A2-4EB3-99C7-DC01E42D25D2}.Debug|x64.Build.0 = Debug|x64 + {3587E506-55A2-4EB3-99C7-DC01E42D25D2}.Debug|x86.ActiveCfg = Debug|x86 + {3587E506-55A2-4EB3-99C7-DC01E42D25D2}.Debug|x86.Build.0 = Debug|x86 + {3587E506-55A2-4EB3-99C7-DC01E42D25D2}.Release|Any CPU.ActiveCfg = Release|Any CPU + {3587E506-55A2-4EB3-99C7-DC01E42D25D2}.Release|Any CPU.Build.0 = Release|Any CPU + {3587E506-55A2-4EB3-99C7-DC01E42D25D2}.Release|ARM.ActiveCfg = Release|Any CPU + {3587E506-55A2-4EB3-99C7-DC01E42D25D2}.Release|ARM.Build.0 = Release|Any CPU + {3587E506-55A2-4EB3-99C7-DC01E42D25D2}.Release|x64.ActiveCfg = Release|Any CPU + {3587E506-55A2-4EB3-99C7-DC01E42D25D2}.Release|x64.Build.0 = Release|Any CPU + {3587E506-55A2-4EB3-99C7-DC01E42D25D2}.Release|x86.ActiveCfg = Release|Any CPU + {3587E506-55A2-4EB3-99C7-DC01E42D25D2}.Release|x86.Build.0 = Release|Any CPU EndGlobalSection GlobalSection(SolutionProperties) = preSolution HideSolutionNode = FALSE @@ -160,8 +165,8 @@ Global {A7FF0C91-25DE-4BA6-B39E-F54E8DADF1CC} = {9248C2E1-B9D6-40BF-81EC-86004D7765B4} {A480EF90-0EAA-4D9A-B271-47A9C47F6F7D} = {32A630A7-2598-41D7-B625-204CD906F5FB} {BD60C727-D8E8-40C3-B8E3-C95A864AE611} = {32A630A7-2598-41D7-B625-204CD906F5FB} - {1A1B7F51-5328-4395-9D9C-07D70965825E} = {32A630A7-2598-41D7-B625-204CD906F5FB} {D9D74F33-6943-49B2-B765-7BD589082098} = {9248C2E1-B9D6-40BF-81EC-86004D7765B4} {FF1F72D6-9524-4422-9497-3CC0002216ED} = {9248C2E1-B9D6-40BF-81EC-86004D7765B4} + {3587E506-55A2-4EB3-99C7-DC01E42D25D2} = {32A630A7-2598-41D7-B625-204CD906F5FB} EndGlobalSection EndGlobal diff --git a/README.md b/README.md index 777e535..faeb120 100644 --- a/README.md +++ b/README.md @@ -20,7 +20,7 @@ MQTTnet is a .NET library for MQTT based communication. It provides a MQTT clien * Lightweight (only the low level implementation of MQTT, no overhead) ## Supported frameworks -* .NET Standard 1.1+ +* .NET Standard 1.3+ * .NET Core 1.1+ * .NET Core App 1.1+ * .NET Framework 4.5.2+ (x86, x64, AnyCPU) @@ -45,7 +45,7 @@ If you use this library and want to see your project here please let me know. # MqttClient ## Example -```c# +```csharp var options = new MqttClientOptions { Server = "localhost" @@ -119,7 +119,7 @@ while (true) ## Example -```c# +```csharp var options = new MqttServerOptions { ConnectionValidator = p => diff --git a/Tests/MQTTnet.Core.Tests/TestMqttServerAdapter.cs b/Tests/MQTTnet.Core.Tests/TestMqttServerAdapter.cs index b1dcf6b..634d5b4 100644 --- a/Tests/MQTTnet.Core.Tests/TestMqttServerAdapter.cs +++ b/Tests/MQTTnet.Core.Tests/TestMqttServerAdapter.cs @@ -8,6 +8,11 @@ namespace MQTTnet.Core.Tests { public event EventHandler ClientConnected; + public void FireClientConnectedEvent(MqttClientConnectedEventArgs eventArgs) + { + ClientConnected?.Invoke(this, eventArgs); + } + public void Start(MqttServerOptions options) { } diff --git a/Tests/MQTTnet.TestApp.UniversalWindows/MQTTnet.TestApp.UniversalWindows.csproj b/Tests/MQTTnet.TestApp.UniversalWindows/MQTTnet.TestApp.UniversalWindows.csproj index 383fd8e..502c3be 100644 --- a/Tests/MQTTnet.TestApp.UniversalWindows/MQTTnet.TestApp.UniversalWindows.csproj +++ b/Tests/MQTTnet.TestApp.UniversalWindows/MQTTnet.TestApp.UniversalWindows.csproj @@ -11,8 +11,8 @@ MQTTnet.TestApp.UniversalWindows en-US UAP - 10.0.14393.0 - 10.0.10240.0 + 10.0.15063.0 + 10.0.15063.0 14 512 {A5A43C5B-DE2A-4C0C-9213-0A381AF9435A};{FAE04EC0-301F-11D3-BF4B-00C04F79EFBC} @@ -137,7 +137,7 @@ - 5.2.3 + 5.3.3 @@ -150,7 +150,7 @@ ;2008 true full - AnyCPU + x86 false prompt MinimumRecommendedRules.ruleset