diff --git a/Build/MQTTnet.nuspec b/Build/MQTTnet.nuspec index 2583897..5fdc919 100644 --- a/Build/MQTTnet.nuspec +++ b/Build/MQTTnet.nuspec @@ -68,8 +68,8 @@ - - + + \ No newline at end of file diff --git a/Build/build.ps1 b/Build/build.ps1 index e74f9f0..e7d86d7 100644 --- a/Build/build.ps1 +++ b/Build/build.ps1 @@ -8,10 +8,11 @@ $path = &$vswhere -latest -products * -requires Microsoft.Component.MSBuild -pro if ($path) { $msbuild = join-path $path 'MSBuild\15.0\Bin\MSBuild.exe' - &$msbuild ..\Frameworks\MQTTnet.Netstandard\MQTTnet.Netstandard.csproj /t:Build /p:Configuration="Release" /p:TargetFramework="net451" /p:FileVersion=$version /p:AssemblyVersion=$version /verbosity:m + &$msbuild ..\Frameworks\MQTTnet.Netstandard\MQTTnet.Netstandard.csproj /t:Build /p:Configuration="Release" /p:TargetFramework="net452" /p:FileVersion=$version /p:AssemblyVersion=$version /verbosity:m &$msbuild ..\Frameworks\MQTTnet.Netstandard\MQTTnet.Netstandard.csproj /t:Build /p:Configuration="Release" /p:TargetFramework="netstandard1.3" /p:FileVersion=$version /p:AssemblyVersion=$version /verbosity:m &$msbuild ..\Frameworks\MQTTnet.Netstandard\MQTTnet.Netstandard.csproj /t:Build /p:Configuration="Release" /p:TargetFramework="uap10.0" /p:FileVersion=$version /p:AssemblyVersion=$version /verbosity:m - &$msbuild ..\Frameworks\MQTTnet.AspNetCore\MQTTnet.AspNetCore.csproj /t:Build /p:Configuration="Release" /p:TargetFramework="netstandard2.0" /p:FileVersion=$version /p:AssemblyVersion=$version /verbosity:m + + &$msbuild ..\Frameworks\MQTTnet.AspNetCore\MQTTnet.AspNetCore.csproj /t:Build /p:Configuration="Release" /p:TargetFramework="netstandard2.0" /p:FileVersion=$version /p:AssemblyVersion=$version /verbosity:m Remove-Item .\NuGet -Force -Recurse New-Item -ItemType Directory -Force -Path .\NuGet diff --git a/Frameworks/MQTTnet.NetStandard/Implementations/MqttServerAdapter.cs b/Frameworks/MQTTnet.NetStandard/Implementations/MqttServerAdapter.cs index 9d807b8..f894233 100644 --- a/Frameworks/MQTTnet.NetStandard/Implementations/MqttServerAdapter.cs +++ b/Frameworks/MQTTnet.NetStandard/Implementations/MqttServerAdapter.cs @@ -1,4 +1,4 @@ -#if NET451 || NETSTANDARD1_3 +#if NET452 || NETSTANDARD1_3 using System; using System.Net; using System.Net.Security; @@ -98,7 +98,7 @@ namespace MQTTnet.Implementations try { //todo: else branch can be used with min dependency NET46 -#if NET451 +#if NET452 var clientSocket = await Task.Factory.FromAsync(_defaultEndpointSocket.BeginAccept, _defaultEndpointSocket.EndAccept, null).ConfigureAwait(false); #else var clientSocket = await _defaultEndpointSocket.AcceptAsync().ConfigureAwait(false); @@ -122,7 +122,7 @@ namespace MQTTnet.Implementations { try { -#if NET451 +#if NET452 var clientSocket = await Task.Factory.FromAsync(_tlsEndpointSocket.BeginAccept, _tlsEndpointSocket.EndAccept, null).ConfigureAwait(false); #else var clientSocket = await _tlsEndpointSocket.AcceptAsync().ConfigureAwait(false); diff --git a/Frameworks/MQTTnet.NetStandard/Implementations/MqttTcpChannel.Uwp.cs b/Frameworks/MQTTnet.NetStandard/Implementations/MqttTcpChannel.Uwp.cs index bd0614f..06fa137 100644 --- a/Frameworks/MQTTnet.NetStandard/Implementations/MqttTcpChannel.Uwp.cs +++ b/Frameworks/MQTTnet.NetStandard/Implementations/MqttTcpChannel.Uwp.cs @@ -32,7 +32,6 @@ namespace MQTTnet.Implementations public Stream SendStream { get; private set; } public Stream ReceiveStream { get; private set; } - public Stream RawReceiveStream { get; private set; } public static Func> CustomIgnorableServerCertificateErrorsResolver { get; set; } @@ -70,9 +69,6 @@ namespace MQTTnet.Implementations public void Dispose() { - RawReceiveStream?.Dispose(); - RawReceiveStream = null; - SendStream?.Dispose(); SendStream = null; @@ -87,7 +83,6 @@ namespace MQTTnet.Implementations { SendStream = _socket.OutputStream.AsStreamForWrite(); ReceiveStream = _socket.InputStream.AsStreamForRead(); - RawReceiveStream = ReceiveStream; } private static Certificate LoadCertificate(MqttClientTcpOptions options) diff --git a/Frameworks/MQTTnet.NetStandard/Implementations/MqttTcpChannel.cs b/Frameworks/MQTTnet.NetStandard/Implementations/MqttTcpChannel.cs index 62bb878..0d6180c 100644 --- a/Frameworks/MQTTnet.NetStandard/Implementations/MqttTcpChannel.cs +++ b/Frameworks/MQTTnet.NetStandard/Implementations/MqttTcpChannel.cs @@ -1,5 +1,4 @@ -#if NET451 || NETSTANDARD1_3 - +#if NET452 || NETSTANDARD1_3 using System; using System.Net.Security; using System.Net.Sockets; @@ -18,7 +17,7 @@ namespace MQTTnet.Implementations private readonly MqttClientTcpOptions _options; //todo: this can be used with min dependency NetStandard1.6 -#if NET45 +#if NET452 // ReSharper disable once MemberCanBePrivate.Global // ReSharper disable once AutoPropertyCanBeMadeGetOnly.Global public static int BufferSize { get; set; } = 4096 * 20; // Can be changed for fine tuning by library user. @@ -49,7 +48,6 @@ namespace MQTTnet.Implementations public Stream SendStream { get; private set; } public Stream ReceiveStream { get; private set; } - public Stream RawReceiveStream { get; private set; } public static Func CustomCertificateValidationCallback { get; set; } @@ -61,7 +59,7 @@ namespace MQTTnet.Implementations } //todo: else brach can be used with min dependency NET46 -#if NET451 +#if NET452 await Task.Factory.FromAsync(_socket.BeginConnect, _socket.EndConnect, _options.Server, _options.GetPort(), null).ConfigureAwait(false); #else await _socket.ConnectAsync(_options.Server, _options.GetPort()).ConfigureAwait(false); @@ -140,19 +138,18 @@ namespace MQTTnet.Implementations private void CreateStreams(Socket socket, Stream sslStream) { - RawReceiveStream = sslStream ?? new NetworkStream(socket); - + var stream = sslStream ?? new NetworkStream(socket); //cannot use this as default buffering prevents from receiving the first connect message //need two streams otherwise read and write have to be synchronized //todo: if branch can be used with min dependency NetStandard1.6 -#if NET45 - SendStream = new BufferedStream(RawReceiveStream, BufferSize); - ReceiveStream = new BufferedStream(RawReceiveStream, BufferSize); +#if NET452 + SendStream = new BufferedStream(stream, BufferSize); + ReceiveStream = new BufferedStream(stream, BufferSize); #else - SendStream = RawReceiveStream; - ReceiveStream = RawReceiveStream; + SendStream = stream; + ReceiveStream = stream; #endif } diff --git a/Frameworks/MQTTnet.NetStandard/MQTTnet.Netstandard.csproj b/Frameworks/MQTTnet.NetStandard/MQTTnet.Netstandard.csproj index 37b7e13..f981d60 100644 --- a/Frameworks/MQTTnet.NetStandard/MQTTnet.Netstandard.csproj +++ b/Frameworks/MQTTnet.NetStandard/MQTTnet.Netstandard.csproj @@ -1,7 +1,7 @@  - netstandard1.3;net451;uap10.0 + netstandard1.3;net452;uap10.0 MQTTnet MQTTnet 2.5.0.0 @@ -18,7 +18,7 @@ false UAP,Version=v10.0 UAP - 10.0.15063.0 + 10.0.16299.0 10.0.10240.0 .NETCore v5.0 diff --git a/MQTTnet.Core/Adapter/MqttChannelCommunicationAdapter.cs b/MQTTnet.Core/Adapter/MqttChannelCommunicationAdapter.cs index b31a870..888539c 100644 --- a/MQTTnet.Core/Adapter/MqttChannelCommunicationAdapter.cs +++ b/MQTTnet.Core/Adapter/MqttChannelCommunicationAdapter.cs @@ -144,7 +144,7 @@ namespace MQTTnet.Core.Adapter ReceivedMqttPacket receivedMqttPacket; if (timeout > TimeSpan.Zero) { - receivedMqttPacket = await ReceiveAsync(_channel.RawReceiveStream, cancellationToken).TimeoutAfter(timeout).ConfigureAwait(false); + receivedMqttPacket = await ReceiveAsync(_channel.ReceiveStream, cancellationToken).TimeoutAfter(timeout).ConfigureAwait(false); } else { diff --git a/MQTTnet.Core/Channel/IMqttCommunicationChannel.cs b/MQTTnet.Core/Channel/IMqttCommunicationChannel.cs index 8c746d1..e7a74c1 100644 --- a/MQTTnet.Core/Channel/IMqttCommunicationChannel.cs +++ b/MQTTnet.Core/Channel/IMqttCommunicationChannel.cs @@ -7,7 +7,6 @@ namespace MQTTnet.Core.Channel { Stream SendStream { get; } Stream ReceiveStream { get; } - Stream RawReceiveStream { get; } Task ConnectAsync(); Task DisconnectAsync(); diff --git a/MQTTnet.Core/Client/MqttClient.cs b/MQTTnet.Core/Client/MqttClient.cs index a8e4eba..5cc70cd 100644 --- a/MQTTnet.Core/Client/MqttClient.cs +++ b/MQTTnet.Core/Client/MqttClient.cs @@ -60,8 +60,8 @@ namespace MQTTnet.Core.Client await _adapter.ConnectAsync(_options.CommunicationTimeout).ConfigureAwait(false); _logger.LogTrace("Connection with server established."); - await SetupIncomingPacketProcessingAsync(); - var connectResponse = await AuthenticateAsync(options.WillMessage); + await SetupIncomingPacketProcessingAsync().ConfigureAwait(false); + var connectResponse = await AuthenticateAsync(options.WillMessage).ConfigureAwait(false); _logger.LogTrace("MQTT connection with server established."); @@ -218,7 +218,7 @@ namespace MQTTnet.Core.Client while (!_isReceivingPackets && _cancellationTokenSource != null && !_cancellationTokenSource.IsCancellationRequested) { - await Task.Delay(TimeSpan.FromMilliseconds(100)); + await Task.Delay(TimeSpan.FromMilliseconds(100)).ConfigureAwait(false); } } diff --git a/MQTTnet.sln b/MQTTnet.sln index 2207c1f..86fee97 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.27004.2002 +VisualStudioVersion = 15.0.27004.2006 MinimumVisualStudioVersion = 10.0.40219.1 Project("{9A19103F-16F7-4668-BE54-9A1E7A4F7556}") = "MQTTnet.Core.Tests", "Tests\MQTTnet.Core.Tests\MQTTnet.Core.Tests.csproj", "{A7FF0C91-25DE-4BA6-B39E-F54E8DADF1CC}" EndProject diff --git a/Tests/MQTTnet.TestApp.NetCore/MQTTnet.TestApp.NetCore.csproj b/Tests/MQTTnet.TestApp.NetCore/MQTTnet.TestApp.NetCore.csproj index 4c0f99d..c4a2bac 100644 --- a/Tests/MQTTnet.TestApp.NetCore/MQTTnet.TestApp.NetCore.csproj +++ b/Tests/MQTTnet.TestApp.NetCore/MQTTnet.TestApp.NetCore.csproj @@ -3,7 +3,7 @@ Exe Full - netcoreapp2.0;net451 + netcoreapp2.0;net452 diff --git a/Tests/MQTTnet.TestApp.NetCore/Program.cs b/Tests/MQTTnet.TestApp.NetCore/Program.cs index 2e1d8c9..4283087 100644 --- a/Tests/MQTTnet.TestApp.NetCore/Program.cs +++ b/Tests/MQTTnet.TestApp.NetCore/Program.cs @@ -83,6 +83,12 @@ namespace MQTTnet.TestApp.NetCore public Task SaveRetainedMessagesAsync(IList messages) { + var directory = Path.GetDirectoryName(Filename); + if (!Directory.Exists(directory)) + { + Directory.CreateDirectory(directory); + } + File.WriteAllText(Filename, JsonConvert.SerializeObject(messages)); return Task.FromResult(0); } diff --git a/Tests/MQTTnet.TestApp.UniversalWindows/MQTTnet.TestApp.UniversalWindows.csproj b/Tests/MQTTnet.TestApp.UniversalWindows/MQTTnet.TestApp.UniversalWindows.csproj index ce511d6..fa0763c 100644 --- a/Tests/MQTTnet.TestApp.UniversalWindows/MQTTnet.TestApp.UniversalWindows.csproj +++ b/Tests/MQTTnet.TestApp.UniversalWindows/MQTTnet.TestApp.UniversalWindows.csproj @@ -11,7 +11,7 @@ MQTTnet.TestApp.UniversalWindows en-US UAP - 10.0.15063.0 + 10.0.16299.0 10.0.15063.0 14 512