From c5978f58453d5377ce36efafb9dc621dbb3cb7e7 Mon Sep 17 00:00:00 2001 From: Christian Kratky Date: Sun, 4 Jun 2017 17:31:58 +0200 Subject: [PATCH] Implement test app for Universal Windows --- .../Implementations/MqttTcpChannel.cs | 2 +- .../Implementations/MqttTcpChannel.cs | 2 +- .../Implementations/MqttTcpChannel.cs | 7 +- .../MQTTnet.UniversalWindows.csproj | 14 +-- .../MQTTnet.UniversalWindows/project.json | 4 +- MQTTnet.Core/Client/MqttClient.cs | 5 +- MQTTnet.sln | 86 +++---------------- .../MQTTnet.TestApp.NetFramework.csproj | 40 +++++++++ Tests/MQTTnet.TestApp.NetFramework/Program.cs | 2 +- .../MQTTnet.TestApp.UniversalWindows.csproj | 50 ++++++++--- .../MainPage.xaml | 28 +++++- .../MainPage.xaml.cs | 71 +++++++++++---- .../project.json | 1 + 13 files changed, 188 insertions(+), 124 deletions(-) diff --git a/Frameworks/MQTTnet.NetCoreApp/Implementations/MqttTcpChannel.cs b/Frameworks/MQTTnet.NetCoreApp/Implementations/MqttTcpChannel.cs index fabe7b9..a5f873c 100644 --- a/Frameworks/MQTTnet.NetCoreApp/Implementations/MqttTcpChannel.cs +++ b/Frameworks/MQTTnet.NetCoreApp/Implementations/MqttTcpChannel.cs @@ -10,7 +10,7 @@ using MQTTnet.Core.Exceptions; namespace MQTTnet.Implementations { - public class MqttTcpChannel : IMqttCommunicationChannel, IDisposable + public sealed class MqttTcpChannel : IMqttCommunicationChannel, IDisposable { private readonly Socket _socket; private SslStream _sslStream; diff --git a/Frameworks/MQTTnet.NetFramework/Implementations/MqttTcpChannel.cs b/Frameworks/MQTTnet.NetFramework/Implementations/MqttTcpChannel.cs index e272c97..adea277 100644 --- a/Frameworks/MQTTnet.NetFramework/Implementations/MqttTcpChannel.cs +++ b/Frameworks/MQTTnet.NetFramework/Implementations/MqttTcpChannel.cs @@ -10,7 +10,7 @@ using MQTTnet.Core.Exceptions; namespace MQTTnet.Implementations { - public class MqttTcpChannel : IMqttCommunicationChannel, IDisposable + public sealed class MqttTcpChannel : IMqttCommunicationChannel, IDisposable { private readonly Socket _socket; private SslStream _sslStream; diff --git a/Frameworks/MQTTnet.UniversalWindows/Implementations/MqttTcpChannel.cs b/Frameworks/MQTTnet.UniversalWindows/Implementations/MqttTcpChannel.cs index 042fcb0..e1e6082 100644 --- a/Frameworks/MQTTnet.UniversalWindows/Implementations/MqttTcpChannel.cs +++ b/Frameworks/MQTTnet.UniversalWindows/Implementations/MqttTcpChannel.cs @@ -13,7 +13,7 @@ using MQTTnet.Core.Exceptions; namespace MQTTnet.Implementations { - public class MqttTcpChannel : IMqttCommunicationChannel, IDisposable + public sealed class MqttTcpChannel : IMqttCommunicationChannel, IDisposable { private readonly StreamSocket _socket; @@ -42,11 +42,10 @@ namespace MQTTnet.Implementations if (!options.SslOptions.CheckCertificateRevocation) { - _socket.Control.IgnorableServerCertificateErrors.Add(ChainValidationResult.Revoked); _socket.Control.IgnorableServerCertificateErrors.Add(ChainValidationResult.IncompleteChain); _socket.Control.IgnorableServerCertificateErrors.Add(ChainValidationResult.RevocationInformationMissing); } - + await _socket.ConnectAsync(new HostName(options.Server), options.GetPort().ToString(), SocketProtectionLevel.Tls12); } } @@ -90,7 +89,7 @@ namespace MQTTnet.Implementations try { - await _socket.InputStream.ReadAsync(buffer.AsBuffer(), (uint)buffer.Length, InputStreamOptions.Partial); + await _socket.InputStream.ReadAsync(buffer.AsBuffer(), (uint)buffer.Length, InputStreamOptions.None); } catch (SocketException exception) { diff --git a/Frameworks/MQTTnet.UniversalWindows/MQTTnet.UniversalWindows.csproj b/Frameworks/MQTTnet.UniversalWindows/MQTTnet.UniversalWindows.csproj index 9022957..fa6f897 100644 --- a/Frameworks/MQTTnet.UniversalWindows/MQTTnet.UniversalWindows.csproj +++ b/Frameworks/MQTTnet.UniversalWindows/MQTTnet.UniversalWindows.csproj @@ -26,6 +26,7 @@ DEBUG;TRACE;NETFX_CORE;WINDOWS_UWP prompt 4 + CS1591 AnyCPU @@ -35,13 +36,14 @@ TRACE;NETFX_CORE;WINDOWS_UWP prompt 4 + CS1591 x86 true bin\x86\Debug\ DEBUG;TRACE;NETFX_CORE;WINDOWS_UWP - ;2008 + ;2008,CS1591 full x86 false @@ -52,7 +54,7 @@ bin\x86\Release\ TRACE;NETFX_CORE;WINDOWS_UWP true - ;2008 + ;2008,CS1591 pdbonly x86 false @@ -64,7 +66,7 @@ true bin\ARM\Debug\ DEBUG;TRACE;NETFX_CORE;WINDOWS_UWP - ;2008 + ;2008,CS1591 full ARM false @@ -75,7 +77,7 @@ bin\ARM\Release\ TRACE;NETFX_CORE;WINDOWS_UWP true - ;2008 + ;2008,CS1591 pdbonly ARM false @@ -87,7 +89,7 @@ true bin\x64\Debug\ DEBUG;TRACE;NETFX_CORE;WINDOWS_UWP - ;2008 + ;2008,CS1591 full x64 false @@ -98,7 +100,7 @@ bin\x64\Release\ TRACE;NETFX_CORE;WINDOWS_UWP true - ;2008 + ;2008,CS1591 pdbonly x64 false diff --git a/Frameworks/MQTTnet.UniversalWindows/project.json b/Frameworks/MQTTnet.UniversalWindows/project.json index 5b39250..239b57e 100644 --- a/Frameworks/MQTTnet.UniversalWindows/project.json +++ b/Frameworks/MQTTnet.UniversalWindows/project.json @@ -3,10 +3,10 @@ "Microsoft.NETCore.UniversalWindowsPlatform": "5.1.0" }, "frameworks": { - "uap10.0": {}, - "netstandard1.1": {} + "uap10.0": {} }, "runtimes": { + "win10": {}, "win10-arm": {}, "win10-arm-aot": {}, "win10-x86": {}, diff --git a/MQTTnet.Core/Client/MqttClient.cs b/MQTTnet.Core/Client/MqttClient.cs index 8529523..72b718e 100644 --- a/MQTTnet.Core/Client/MqttClient.cs +++ b/MQTTnet.Core/Client/MqttClient.cs @@ -74,6 +74,7 @@ namespace MQTTnet.Core.Client var response = await SendAndReceiveAsync(connectPacket); if (response.ConnectReturnCode != MqttConnectReturnCode.ConnectionAccepted) { + await DisconnectAsync(); throw new MqttConnectingFailedException(response.ConnectReturnCode); } @@ -190,7 +191,7 @@ namespace MQTTnet.Core.Client } } - private async void ProcessReceivedPacket(MqttBasePacket mqttPacket) + private async void ProcessReceivedPacketAsync(MqttBasePacket mqttPacket) { try { @@ -355,7 +356,7 @@ namespace MQTTnet.Core.Client MqttTrace.Information(nameof(MqttClient), $"Received <<< {mqttPacket}"); #pragma warning disable CS4014 // Because this call is not awaited, execution of the current method continues before the call is completed - Task.Run(() => ProcessReceivedPacket(mqttPacket), cancellationToken); + Task.Run(() => ProcessReceivedPacketAsync(mqttPacket), cancellationToken); #pragma warning restore CS4014 // Because this call is not awaited, execution of the current method continues before the call is completed } } diff --git a/MQTTnet.sln b/MQTTnet.sln index 1053400..8b8d283 100644 --- a/MQTTnet.sln +++ b/MQTTnet.sln @@ -28,10 +28,6 @@ Project("{FAE04EC0-301F-11D3-BF4B-00C04F79EFBC}") = "MQTTnet.TestApp.UniversalWi EndProject Global GlobalSection(SolutionConfigurationPlatforms) = preSolution - Any CPU|Any CPU = Any CPU|Any CPU - Any CPU|ARM = Any CPU|ARM - Any CPU|x64 = Any CPU|x64 - Any CPU|x86 = Any CPU|x86 Debug|Any CPU = Debug|Any CPU Debug|ARM = Debug|ARM Debug|x64 = Debug|x64 @@ -42,14 +38,6 @@ Global Release|x86 = Release|x86 EndGlobalSection GlobalSection(ProjectConfigurationPlatforms) = postSolution - {A7FF0C91-25DE-4BA6-B39E-F54E8DADF1CC}.Any CPU|Any CPU.ActiveCfg = Any CPU|Any CPU - {A7FF0C91-25DE-4BA6-B39E-F54E8DADF1CC}.Any CPU|Any CPU.Build.0 = Any CPU|Any CPU - {A7FF0C91-25DE-4BA6-B39E-F54E8DADF1CC}.Any CPU|ARM.ActiveCfg = Any CPU|Any CPU - {A7FF0C91-25DE-4BA6-B39E-F54E8DADF1CC}.Any CPU|ARM.Build.0 = Any CPU|Any CPU - {A7FF0C91-25DE-4BA6-B39E-F54E8DADF1CC}.Any CPU|x64.ActiveCfg = Any CPU|x64 - {A7FF0C91-25DE-4BA6-B39E-F54E8DADF1CC}.Any CPU|x64.Build.0 = Any CPU|x64 - {A7FF0C91-25DE-4BA6-B39E-F54E8DADF1CC}.Any CPU|x86.ActiveCfg = Any CPU|x86 - {A7FF0C91-25DE-4BA6-B39E-F54E8DADF1CC}.Any CPU|x86.Build.0 = Any CPU|x86 {A7FF0C91-25DE-4BA6-B39E-F54E8DADF1CC}.Debug|Any CPU.ActiveCfg = Debug|Any CPU {A7FF0C91-25DE-4BA6-B39E-F54E8DADF1CC}.Debug|Any CPU.Build.0 = Debug|Any CPU {A7FF0C91-25DE-4BA6-B39E-F54E8DADF1CC}.Debug|ARM.ActiveCfg = Debug|Any CPU @@ -66,14 +54,6 @@ Global {A7FF0C91-25DE-4BA6-B39E-F54E8DADF1CC}.Release|x64.Build.0 = Release|x64 {A7FF0C91-25DE-4BA6-B39E-F54E8DADF1CC}.Release|x86.ActiveCfg = Release|x86 {A7FF0C91-25DE-4BA6-B39E-F54E8DADF1CC}.Release|x86.Build.0 = Release|x86 - {A480EF90-0EAA-4D9A-B271-47A9C47F6F7D}.Any CPU|Any CPU.ActiveCfg = Any CPU|Any CPU - {A480EF90-0EAA-4D9A-B271-47A9C47F6F7D}.Any CPU|Any CPU.Build.0 = Any CPU|Any CPU - {A480EF90-0EAA-4D9A-B271-47A9C47F6F7D}.Any CPU|ARM.ActiveCfg = Any CPU|Any CPU - {A480EF90-0EAA-4D9A-B271-47A9C47F6F7D}.Any CPU|ARM.Build.0 = Any CPU|Any CPU - {A480EF90-0EAA-4D9A-B271-47A9C47F6F7D}.Any CPU|x64.ActiveCfg = Any CPU|x64 - {A480EF90-0EAA-4D9A-B271-47A9C47F6F7D}.Any CPU|x64.Build.0 = Any CPU|x64 - {A480EF90-0EAA-4D9A-B271-47A9C47F6F7D}.Any CPU|x86.ActiveCfg = Any CPU|x86 - {A480EF90-0EAA-4D9A-B271-47A9C47F6F7D}.Any CPU|x86.Build.0 = Any CPU|x86 {A480EF90-0EAA-4D9A-B271-47A9C47F6F7D}.Debug|Any CPU.ActiveCfg = Debug|Any CPU {A480EF90-0EAA-4D9A-B271-47A9C47F6F7D}.Debug|Any CPU.Build.0 = Debug|Any CPU {A480EF90-0EAA-4D9A-B271-47A9C47F6F7D}.Debug|ARM.ActiveCfg = Debug|Any CPU @@ -90,16 +70,7 @@ Global {A480EF90-0EAA-4D9A-B271-47A9C47F6F7D}.Release|x64.Build.0 = Release|x64 {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}.Any CPU|Any CPU.ActiveCfg = Any CPU|Any CPU - {BD60C727-D8E8-40C3-B8E3-C95A864AE611}.Any CPU|Any CPU.Build.0 = Any CPU|Any CPU - {BD60C727-D8E8-40C3-B8E3-C95A864AE611}.Any CPU|ARM.ActiveCfg = Any CPU|ARM - {BD60C727-D8E8-40C3-B8E3-C95A864AE611}.Any CPU|ARM.Build.0 = Any CPU|ARM - {BD60C727-D8E8-40C3-B8E3-C95A864AE611}.Any CPU|x64.ActiveCfg = Any CPU|x64 - {BD60C727-D8E8-40C3-B8E3-C95A864AE611}.Any CPU|x64.Build.0 = Any CPU|x64 - {BD60C727-D8E8-40C3-B8E3-C95A864AE611}.Any CPU|x86.ActiveCfg = Any CPU|x86 - {BD60C727-D8E8-40C3-B8E3-C95A864AE611}.Any CPU|x86.Build.0 = Any CPU|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 @@ -107,21 +78,12 @@ 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 {BD60C727-D8E8-40C3-B8E3-C95A864AE611}.Release|x64.Build.0 = Release|x64 {BD60C727-D8E8-40C3-B8E3-C95A864AE611}.Release|x86.ActiveCfg = Release|x86 {BD60C727-D8E8-40C3-B8E3-C95A864AE611}.Release|x86.Build.0 = Release|x86 - {2ECB99E4-72D0-4C23-99BA-93D511D3967D}.Any CPU|Any CPU.ActiveCfg = Any CPU|Any CPU - {2ECB99E4-72D0-4C23-99BA-93D511D3967D}.Any CPU|Any CPU.Build.0 = Any CPU|Any CPU - {2ECB99E4-72D0-4C23-99BA-93D511D3967D}.Any CPU|ARM.ActiveCfg = Any CPU|Any CPU - {2ECB99E4-72D0-4C23-99BA-93D511D3967D}.Any CPU|ARM.Build.0 = Any CPU|Any CPU - {2ECB99E4-72D0-4C23-99BA-93D511D3967D}.Any CPU|x64.ActiveCfg = Any CPU|x64 - {2ECB99E4-72D0-4C23-99BA-93D511D3967D}.Any CPU|x64.Build.0 = Any CPU|x64 - {2ECB99E4-72D0-4C23-99BA-93D511D3967D}.Any CPU|x86.ActiveCfg = Any CPU|x86 - {2ECB99E4-72D0-4C23-99BA-93D511D3967D}.Any CPU|x86.Build.0 = Any CPU|x86 {2ECB99E4-72D0-4C23-99BA-93D511D3967D}.Debug|Any CPU.ActiveCfg = Debug|Any CPU {2ECB99E4-72D0-4C23-99BA-93D511D3967D}.Debug|Any CPU.Build.0 = Debug|Any CPU {2ECB99E4-72D0-4C23-99BA-93D511D3967D}.Debug|ARM.ActiveCfg = Debug|Any CPU @@ -138,14 +100,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}.Any CPU|Any CPU.ActiveCfg = Any CPU|Any CPU - {1A1B7F51-5328-4395-9D9C-07D70965825E}.Any CPU|Any CPU.Build.0 = Any CPU|Any CPU - {1A1B7F51-5328-4395-9D9C-07D70965825E}.Any CPU|ARM.ActiveCfg = Any CPU|Any CPU - {1A1B7F51-5328-4395-9D9C-07D70965825E}.Any CPU|ARM.Build.0 = Any CPU|Any CPU - {1A1B7F51-5328-4395-9D9C-07D70965825E}.Any CPU|x64.ActiveCfg = Any CPU|x64 - {1A1B7F51-5328-4395-9D9C-07D70965825E}.Any CPU|x64.Build.0 = Any CPU|x64 - {1A1B7F51-5328-4395-9D9C-07D70965825E}.Any CPU|x86.ActiveCfg = Any CPU|x86 - {1A1B7F51-5328-4395-9D9C-07D70965825E}.Any CPU|x86.Build.0 = Any CPU|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 @@ -162,43 +116,23 @@ Global {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}.Any CPU|Any CPU.ActiveCfg = Release|Any CPU - {D9D74F33-6943-49B2-B765-7BD589082098}.Any CPU|Any CPU.Build.0 = Release|Any CPU - {D9D74F33-6943-49B2-B765-7BD589082098}.Any CPU|ARM.ActiveCfg = Release|Any CPU - {D9D74F33-6943-49B2-B765-7BD589082098}.Any CPU|ARM.Build.0 = Release|Any CPU - {D9D74F33-6943-49B2-B765-7BD589082098}.Any CPU|x64.ActiveCfg = Release|Any CPU - {D9D74F33-6943-49B2-B765-7BD589082098}.Any CPU|x64.Build.0 = Release|Any CPU - {D9D74F33-6943-49B2-B765-7BD589082098}.Any CPU|x86.ActiveCfg = Release|Any CPU - {D9D74F33-6943-49B2-B765-7BD589082098}.Any CPU|x86.Build.0 = Release|Any CPU {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 {D9D74F33-6943-49B2-B765-7BD589082098}.Debug|ARM.Build.0 = Debug|Any CPU - {D9D74F33-6943-49B2-B765-7BD589082098}.Debug|x64.ActiveCfg = Debug|Any CPU - {D9D74F33-6943-49B2-B765-7BD589082098}.Debug|x64.Build.0 = Debug|Any CPU - {D9D74F33-6943-49B2-B765-7BD589082098}.Debug|x86.ActiveCfg = Debug|Any CPU - {D9D74F33-6943-49B2-B765-7BD589082098}.Debug|x86.Build.0 = Debug|Any CPU + {D9D74F33-6943-49B2-B765-7BD589082098}.Debug|x64.ActiveCfg = Debug|x64 + {D9D74F33-6943-49B2-B765-7BD589082098}.Debug|x64.Build.0 = Debug|x64 + {D9D74F33-6943-49B2-B765-7BD589082098}.Debug|x86.ActiveCfg = Debug|x86 + {D9D74F33-6943-49B2-B765-7BD589082098}.Debug|x86.Build.0 = Debug|x86 {D9D74F33-6943-49B2-B765-7BD589082098}.Release|Any CPU.ActiveCfg = Release|Any CPU {D9D74F33-6943-49B2-B765-7BD589082098}.Release|Any CPU.Build.0 = Release|Any CPU {D9D74F33-6943-49B2-B765-7BD589082098}.Release|ARM.ActiveCfg = Release|Any CPU {D9D74F33-6943-49B2-B765-7BD589082098}.Release|ARM.Build.0 = Release|Any CPU - {D9D74F33-6943-49B2-B765-7BD589082098}.Release|x64.ActiveCfg = Release|Any CPU - {D9D74F33-6943-49B2-B765-7BD589082098}.Release|x64.Build.0 = Release|Any CPU - {D9D74F33-6943-49B2-B765-7BD589082098}.Release|x86.ActiveCfg = Release|Any CPU - {D9D74F33-6943-49B2-B765-7BD589082098}.Release|x86.Build.0 = Release|Any CPU - {FF1F72D6-9524-4422-9497-3CC0002216ED}.Any CPU|Any CPU.ActiveCfg = Release|x64 - {FF1F72D6-9524-4422-9497-3CC0002216ED}.Any CPU|Any CPU.Build.0 = Release|x64 - {FF1F72D6-9524-4422-9497-3CC0002216ED}.Any CPU|Any CPU.Deploy.0 = Release|x64 - {FF1F72D6-9524-4422-9497-3CC0002216ED}.Any CPU|ARM.ActiveCfg = Release|ARM - {FF1F72D6-9524-4422-9497-3CC0002216ED}.Any CPU|ARM.Build.0 = Release|ARM - {FF1F72D6-9524-4422-9497-3CC0002216ED}.Any CPU|ARM.Deploy.0 = Release|ARM - {FF1F72D6-9524-4422-9497-3CC0002216ED}.Any CPU|x64.ActiveCfg = Release|x64 - {FF1F72D6-9524-4422-9497-3CC0002216ED}.Any CPU|x64.Build.0 = Release|x64 - {FF1F72D6-9524-4422-9497-3CC0002216ED}.Any CPU|x64.Deploy.0 = Release|x64 - {FF1F72D6-9524-4422-9497-3CC0002216ED}.Any CPU|x86.ActiveCfg = Release|x86 - {FF1F72D6-9524-4422-9497-3CC0002216ED}.Any CPU|x86.Build.0 = Release|x86 - {FF1F72D6-9524-4422-9497-3CC0002216ED}.Any CPU|x86.Deploy.0 = Release|x86 - {FF1F72D6-9524-4422-9497-3CC0002216ED}.Debug|Any CPU.ActiveCfg = Debug|x86 + {D9D74F33-6943-49B2-B765-7BD589082098}.Release|x64.ActiveCfg = Release|x64 + {D9D74F33-6943-49B2-B765-7BD589082098}.Release|x64.Build.0 = Release|x64 + {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|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 @@ -208,7 +142,7 @@ Global {FF1F72D6-9524-4422-9497-3CC0002216ED}.Debug|x86.ActiveCfg = Debug|x86 {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|x86 + {FF1F72D6-9524-4422-9497-3CC0002216ED}.Release|Any CPU.ActiveCfg = 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 diff --git a/Tests/MQTTnet.TestApp.NetFramework/MQTTnet.TestApp.NetFramework.csproj b/Tests/MQTTnet.TestApp.NetFramework/MQTTnet.TestApp.NetFramework.csproj index 5c91b3a..c865621 100644 --- a/Tests/MQTTnet.TestApp.NetFramework/MQTTnet.TestApp.NetFramework.csproj +++ b/Tests/MQTTnet.TestApp.NetFramework/MQTTnet.TestApp.NetFramework.csproj @@ -31,6 +31,46 @@ prompt 4 + + true + bin\x86\Debug\ + DEBUG;TRACE + full + x86 + prompt + MinimumRecommendedRules.ruleset + true + + + bin\x86\Release\ + TRACE + true + pdbonly + x86 + prompt + MinimumRecommendedRules.ruleset + true + + + true + bin\x64\Debug\ + DEBUG;TRACE + full + x64 + prompt + MinimumRecommendedRules.ruleset + true + + + bin\x64\Release\ + TRACE + true + pdbonly + x64 + prompt + MinimumRecommendedRules.ruleset + true + diff --git a/Tests/MQTTnet.TestApp.NetFramework/Program.cs b/Tests/MQTTnet.TestApp.NetFramework/Program.cs index 6ec31cd..824cc78 100644 --- a/Tests/MQTTnet.TestApp.NetFramework/Program.cs +++ b/Tests/MQTTnet.TestApp.NetFramework/Program.cs @@ -121,7 +121,7 @@ namespace MQTTnet.TestApp.NetFramework } } - private static async Task RunServerAsync(string[] arguments) + private static void RunServerAsync(string[] arguments) { MqttTrace.TraceMessagePublished += (s, e) => { diff --git a/Tests/MQTTnet.TestApp.UniversalWindows/MQTTnet.TestApp.UniversalWindows.csproj b/Tests/MQTTnet.TestApp.UniversalWindows/MQTTnet.TestApp.UniversalWindows.csproj index e2ea210..ef8020a 100644 --- a/Tests/MQTTnet.TestApp.UniversalWindows/MQTTnet.TestApp.UniversalWindows.csproj +++ b/Tests/MQTTnet.TestApp.UniversalWindows/MQTTnet.TestApp.UniversalWindows.csproj @@ -1,10 +1,10 @@ - + Debug x86 - {ff1f72d6-9524-4422-9497-3cc0002216ed} + {FF1F72D6-9524-4422-9497-3CC0002216ED} AppContainerExe Properties MQTTnet.TestApp.UniversalWindows @@ -17,9 +17,7 @@ 512 {A5A43C5B-DE2A-4C0C-9213-0A381AF9435A};{FAE04EC0-301F-11D3-BF4B-00C04F79EFBC} true - MQTTnet.TestApp.UniversalWindows_TemporaryKey.pfx - true @@ -90,12 +88,10 @@ true true - - App.xaml @@ -109,9 +105,7 @@ Designer - - @@ -133,11 +127,45 @@ Designer - + + + {bd60c727-d8e8-40c3-b8e3-c95a864ae611} + MQTTnet.UniversalWindows + + + {2ecb99e4-72d0-4c23-99ba-93d511d3967d} + MQTTnet.Core + + 14.0 - + + true + bin\Debug\ + DEBUG;TRACE;NETFX_CORE;WINDOWS_UWP;CODE_ANALYSIS + ;2008 + true + full + AnyCPU + false + prompt + MinimumRecommendedRules.ruleset + true + + + bin\Release\ + TRACE;NETFX_CORE;WINDOWS_UWP;CODE_ANALYSIS + true + ;2008 + true + pdbonly + AnyCPU + false + prompt + MinimumRecommendedRules.ruleset + true + - + \ No newline at end of file diff --git a/Tests/MQTTnet.TestApp.UniversalWindows/MainPage.xaml b/Tests/MQTTnet.TestApp.UniversalWindows/MainPage.xaml index 3beb053..e61b6e5 100644 --- a/Tests/MQTTnet.TestApp.UniversalWindows/MainPage.xaml +++ b/Tests/MQTTnet.TestApp.UniversalWindows/MainPage.xaml @@ -7,7 +7,33 @@ xmlns:mc="http://schemas.openxmlformats.org/markup-compatibility/2006" mc:Ignorable="d"> - + + + + + + + + + Server: + + User: + + Password: + + ClientId: + + + Use SSL + + Trace: + + + + + + + diff --git a/Tests/MQTTnet.TestApp.UniversalWindows/MainPage.xaml.cs b/Tests/MQTTnet.TestApp.UniversalWindows/MainPage.xaml.cs index 3b13a55..0a74135 100644 --- a/Tests/MQTTnet.TestApp.UniversalWindows/MainPage.xaml.cs +++ b/Tests/MQTTnet.TestApp.UniversalWindows/MainPage.xaml.cs @@ -1,30 +1,63 @@ using System; -using System.Collections.Generic; -using System.IO; -using System.Linq; -using System.Runtime.InteropServices.WindowsRuntime; -using Windows.Foundation; -using Windows.Foundation.Collections; +using Windows.UI.Core; using Windows.UI.Xaml; -using Windows.UI.Xaml.Controls; -using Windows.UI.Xaml.Controls.Primitives; -using Windows.UI.Xaml.Data; -using Windows.UI.Xaml.Input; -using Windows.UI.Xaml.Media; -using Windows.UI.Xaml.Navigation; - -// The Blank Page item template is documented at https://go.microsoft.com/fwlink/?LinkId=402352&clcid=0x409 +using MQTTnet.Core.Client; +using MQTTnet.Core.Diagnostics; namespace MQTTnet.TestApp.UniversalWindows { - /// - /// An empty page that can be used on its own or navigated to within a Frame. - /// - public sealed partial class MainPage : Page + public sealed partial class MainPage { + private MqttClient _mqttClient; + public MainPage() { - this.InitializeComponent(); + InitializeComponent(); + + MqttTrace.TraceMessagePublished += OnTraceMessagePublished; + } + + private async void OnTraceMessagePublished(object sender, MqttTraceMessagePublishedEventArgs e) + { + await Trace.Dispatcher.RunAsync(CoreDispatcherPriority.High, () => + { + var text = $"[{DateTime.Now:O}] [{e.Level}] [{e.Source}] [{e.ThreadId}] [{e.Message}]{Environment.NewLine}"; + if (e.Exception != null) + { + text += $"{e.Exception}{Environment.NewLine}"; + } + + Trace.Text += text; + }); + } + + private async void Connect(object sender, RoutedEventArgs e) + { + var options = new MqttClientOptions + { + Server = Server.Text, + UserName = User.Text, + Password = Password.Text, + ClientId = ClientId.Text + }; + + options.SslOptions.UseSsl = UseSsl.IsChecked == true; + + try + { + if (_mqttClient != null) + { + await _mqttClient.DisconnectAsync(); + } + + var factory = new MqttClientFactory(); + _mqttClient = factory.CreateMqttClient(options); + await _mqttClient.ConnectAsync(); + } + catch (Exception exception) + { + Trace.Text += exception + Environment.NewLine; + } } } } diff --git a/Tests/MQTTnet.TestApp.UniversalWindows/project.json b/Tests/MQTTnet.TestApp.UniversalWindows/project.json index 77bf149..0cf15cf 100644 --- a/Tests/MQTTnet.TestApp.UniversalWindows/project.json +++ b/Tests/MQTTnet.TestApp.UniversalWindows/project.json @@ -6,6 +6,7 @@ "uap10.0": {} }, "runtimes": { + "win10": {}, "win10-arm": {}, "win10-arm-aot": {}, "win10-x86": {},