diff --git a/Build/MQTTnet.AspNetCore.nuspec b/Build/MQTTnet.AspNetCore.nuspec index 61fc1214..24036cf6 100644 --- a/Build/MQTTnet.AspNetCore.nuspec +++ b/Build/MQTTnet.AspNetCore.nuspec @@ -8,6 +8,7 @@ LICENSE https://github.com/chkr1011/MQTTnet https://raw.githubusercontent.com/chkr1011/MQTTnet/master/Images/Logo_128x128.png + images\Logo_128x128.png false This is a support library to integrate MQTTnet into AspNetCore. For release notes please go to MQTTnet release notes (https://www.nuget.org/packages/MQTTnet/). @@ -27,6 +28,9 @@ + + + diff --git a/Build/MQTTnet.Extensions.ManagedClient.nuspec b/Build/MQTTnet.Extensions.ManagedClient.nuspec index 8ae373fa..2e01b3e3 100644 --- a/Build/MQTTnet.Extensions.ManagedClient.nuspec +++ b/Build/MQTTnet.Extensions.ManagedClient.nuspec @@ -8,6 +8,7 @@ LICENSE https://github.com/chkr1011/MQTTnet https://raw.githubusercontent.com/chkr1011/MQTTnet/master/Images/Logo_128x128.png + images\Logo_128x128.png false This is an extension library which provides a managed MQTT client with additional features using MQTTnet. For release notes please go to MQTTnet release notes (https://www.nuget.org/packages/MQTTnet/). @@ -22,6 +23,9 @@ + + + diff --git a/Build/MQTTnet.Extensions.Rpc.nuspec b/Build/MQTTnet.Extensions.Rpc.nuspec index 4089ae4c..35c0d040 100644 --- a/Build/MQTTnet.Extensions.Rpc.nuspec +++ b/Build/MQTTnet.Extensions.Rpc.nuspec @@ -8,6 +8,7 @@ LICENSE https://github.com/chkr1011/MQTTnet https://raw.githubusercontent.com/chkr1011/MQTTnet/master/Images/Logo_128x128.png + images\Logo_128x128.png false This is an extension library which allows executing synchronous device calls including a response using MQTTnet. For release notes please go to MQTTnet release notes (https://www.nuget.org/packages/MQTTnet/). @@ -22,6 +23,9 @@ + + + diff --git a/Build/MQTTnet.Extensions.WebSocket4Net.nuspec b/Build/MQTTnet.Extensions.WebSocket4Net.nuspec index 0baacddd..c5643174 100644 --- a/Build/MQTTnet.Extensions.WebSocket4Net.nuspec +++ b/Build/MQTTnet.Extensions.WebSocket4Net.nuspec @@ -8,6 +8,7 @@ LICENSE https://github.com/chkr1011/MQTTnet https://raw.githubusercontent.com/chkr1011/MQTTnet/master/Images/Logo_128x128.png + images\Logo_128x128.png false This is an extension library which allows using _WebSocket4Net_ as transport for MQTTnet clients. For release notes please go to MQTTnet release notes (https://www.nuget.org/packages/MQTTnet/). @@ -22,6 +23,9 @@ + + + diff --git a/Build/MQTTnet.NETStandard.nuspec b/Build/MQTTnet.NETStandard.nuspec index ef1b3fac..c0b138cb 100644 --- a/Build/MQTTnet.NETStandard.nuspec +++ b/Build/MQTTnet.NETStandard.nuspec @@ -8,6 +8,7 @@ LICENSE https://github.com/chkr1011/MQTTnet https://raw.githubusercontent.com/chkr1011/MQTTnet/master/Images/Logo_128x128.png + images\Logo_128x128.png false This package contains the .NET Standard version of MQTTnet only. For release notes please go to MQTTnet release notes (https://www.nuget.org/packages/MQTTnet/). @@ -33,6 +34,9 @@ + + + diff --git a/Build/MQTTnet.nuspec b/Build/MQTTnet.nuspec index 9e256874..c6c35b10 100644 --- a/Build/MQTTnet.nuspec +++ b/Build/MQTTnet.nuspec @@ -8,6 +8,7 @@ LICENSE https://github.com/chkr1011/MQTTnet https://raw.githubusercontent.com/chkr1011/MQTTnet/master/Images/Logo_128x128.png + images\Logo_128x128.png false MQTTnet is a high performance .NET library for MQTT based communication. It provides a MQTT client and a MQTT server (broker) and supports v3.1.0, v3.1.1 and v5.0.0 of the MQTT protocol. @@ -55,6 +56,9 @@ + + + diff --git a/Build/build.ps1 b/Build/build.ps1 index 36c6eab4..215fb540 100644 --- a/Build/build.ps1 +++ b/Build/build.ps1 @@ -84,8 +84,8 @@ Remove-Item "nuget.exe" -Force -Recurse -ErrorAction SilentlyContinue # Build MQTTnet.Server Portable &dotnet publish ..\Source\MQTTnet.Server\MQTTnet.Server.csproj --configuration Release /p:FileVersion=$assemblyVersion /p:Version=$nugetVersion -$source = "..\Source\MQTTnet.Server\bin\Release\netcoreapp3.1\publish" -$destination = "..\Source\MQTTnet.Server\bin\MQTTnet.Server-Portable-v$nugetVersion.zip" +$source = (Convert-Path .) + "\..\Source\MQTTnet.Server\bin\Release\netcoreapp3.1\publish" +$destination = (Convert-Path .) + "\..\Source\MQTTnet.Server\bin\MQTTnet.Server-Portable-v$nugetVersion.zip" If(Test-path $destination) {Remove-item $destination} Add-Type -assembly "system.io.compression.filesystem" [io.compression.zipfile]::CreateFromDirectory($source, $destination) @@ -95,8 +95,8 @@ If(Test-path $destination) {Remove-item $destination} # Build MQTTnet.Server Linux-x64 &dotnet publish ..\Source\MQTTnet.Server\MQTTnet.Server.csproj --configuration Release /p:FileVersion=$assemblyVersion /p:Version=$nugetVersion --self-contained --runtime linux-x64 -$source = "..\Source\MQTTnet.Server\bin\Release\netcoreapp3.1\linux-x64\publish" -$destination = "..\Source\MQTTnet.Server\bin\MQTTnet.Server-Linux-x64-v$nugetVersion.zip" +$source = (Convert-Path .) + "\..\Source\MQTTnet.Server\bin\Release\netcoreapp3.1\linux-x64\publish" +$destination = (Convert-Path .) + "\..\Source\MQTTnet.Server\bin\MQTTnet.Server-Linux-x64-v$nugetVersion.zip" If(Test-path $destination) {Remove-item $destination} Add-Type -assembly "system.io.compression.filesystem" [io.compression.zipfile]::CreateFromDirectory($source, $destination) @@ -106,8 +106,8 @@ If(Test-path $destination) {Remove-item $destination} # Build MQTTnet.Server Linux-ARM &dotnet publish ..\Source\MQTTnet.Server\MQTTnet.Server.csproj --configuration Release /p:FileVersion=$assemblyVersion /p:Version=$nugetVersion --self-contained --runtime linux-arm -$source = "..\Source\MQTTnet.Server\bin\Release\netcoreapp3.1\linux-ARM\publish" -$destination = "..\Source\MQTTnet.Server\bin\MQTTnet.Server-Linux-ARM-v$nugetVersion.zip" +$source = (Convert-Path .) + "\..\Source\MQTTnet.Server\bin\Release\netcoreapp3.1\linux-ARM\publish" +$destination = (Convert-Path .) + "\..\Source\MQTTnet.Server\bin\MQTTnet.Server-Linux-ARM-v$nugetVersion.zip" If(Test-path $destination) {Remove-item $destination} Add-Type -assembly "system.io.compression.filesystem" [io.compression.zipfile]::CreateFromDirectory($source, $destination) @@ -117,8 +117,8 @@ If(Test-path $destination) {Remove-item $destination} # Build MQTTnet.Server Windows-x64 &dotnet publish ..\Source\MQTTnet.Server\MQTTnet.Server.csproj --configuration Release /p:FileVersion=$assemblyVersion /p:Version=$nugetVersion --self-contained --runtime win-x64 -$source = "..\Source\MQTTnet.Server\bin\Release\netcoreapp3.1\win-x64\publish" -$destination = "..\Source\MQTTnet.Server\bin\MQTTnet.Server-Windows-x64-v$nugetVersion.zip" +$source = (Convert-Path .) + "\..\Source\MQTTnet.Server\bin\Release\netcoreapp3.1\win-x64\publish" +$destination = (Convert-Path .) + "\..\Source\MQTTnet.Server\bin\MQTTnet.Server-Windows-x64-v$nugetVersion.zip" If(Test-path $destination) {Remove-item $destination} Add-Type -assembly "system.io.compression.filesystem" [io.compression.zipfile]::CreateFromDirectory($source, $destination) diff --git a/Documents/Import_CodeSigningKey.md b/Documents/Import_CodeSigningKey.md index 7e966e4a..f14add98 100644 --- a/Documents/Import_CodeSigningKey.md +++ b/Documents/Import_CodeSigningKey.md @@ -1,9 +1,9 @@ # Import codeSigningKey.pfx In order to import the key for code signing on a new developer machine use the following command within the VS developer command line: -> sn –i codeSigningKey.pfx VS_KEY_EFCA4C5B6DFD4B4F +sn –i .\codeSigningKey.pfx VS_KEY_62CA73019ED23333 The container name may be different. # Check if the assembly has a strong name -> sn -vf MQTTnet.dll \ No newline at end of file +sn -vf MQTTnet.dll \ No newline at end of file diff --git a/Source/MQTTnet.AspnetCore/Client/Tcp/TcpConnection.cs b/Source/MQTTnet.AspnetCore/Client/Tcp/TcpConnection.cs index 4cc16683..ad803fbf 100644 --- a/Source/MQTTnet.AspnetCore/Client/Tcp/TcpConnection.cs +++ b/Source/MQTTnet.AspnetCore/Client/Tcp/TcpConnection.cs @@ -1,13 +1,13 @@ -using System; +using Microsoft.AspNetCore.Connections; +using Microsoft.AspNetCore.Http.Features; +using MQTTnet.Exceptions; +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.AspNetCore.Client.Tcp { @@ -43,7 +43,7 @@ namespace MQTTnet.AspNetCore.Client.Tcp #if NETCOREAPP3_1 public override ValueTask DisposeAsync() #else - public Task DisposeAsync() + public new Task DisposeAsync() #endif { IsConnected = false; diff --git a/Source/MQTTnet.Server/Mqtt/MqttServerService.cs b/Source/MQTTnet.Server/Mqtt/MqttServerService.cs index 9bcb42c5..8e5c0435 100644 --- a/Source/MQTTnet.Server/Mqtt/MqttServerService.cs +++ b/Source/MQTTnet.Server/Mqtt/MqttServerService.cs @@ -21,21 +21,21 @@ namespace MQTTnet.Server.Mqtt { public class MqttServerService { - private readonly ILogger _logger; + readonly ILogger _logger; - private readonly MqttSettingsModel _settings; - private readonly MqttApplicationMessageInterceptor _mqttApplicationMessageInterceptor; - private readonly MqttServerStorage _mqttServerStorage; - private readonly MqttClientConnectedHandler _mqttClientConnectedHandler; - private readonly MqttClientDisconnectedHandler _mqttClientDisconnectedHandler; - private readonly MqttClientSubscribedTopicHandler _mqttClientSubscribedTopicHandler; - private readonly MqttClientUnsubscribedTopicHandler _mqttClientUnsubscribedTopicHandler; - private readonly MqttServerConnectionValidator _mqttConnectionValidator; - private readonly IMqttServer _mqttServer; - private readonly MqttSubscriptionInterceptor _mqttSubscriptionInterceptor; - private readonly MqttUnsubscriptionInterceptor _mqttUnsubscriptionInterceptor; - private readonly PythonScriptHostService _pythonScriptHostService; - private readonly MqttWebSocketServerAdapter _webSocketServerAdapter; + readonly MqttSettingsModel _settings; + readonly MqttApplicationMessageInterceptor _mqttApplicationMessageInterceptor; + readonly MqttServerStorage _mqttServerStorage; + readonly MqttClientConnectedHandler _mqttClientConnectedHandler; + readonly MqttClientDisconnectedHandler _mqttClientDisconnectedHandler; + readonly MqttClientSubscribedTopicHandler _mqttClientSubscribedTopicHandler; + readonly MqttClientUnsubscribedTopicHandler _mqttClientUnsubscribedTopicHandler; + readonly MqttServerConnectionValidator _mqttConnectionValidator; + readonly IMqttServer _mqttServer; + readonly MqttSubscriptionInterceptor _mqttSubscriptionInterceptor; + readonly MqttUnsubscriptionInterceptor _mqttUnsubscriptionInterceptor; + readonly PythonScriptHostService _pythonScriptHostService; + readonly MqttWebSocketServerAdapter _webSocketServerAdapter; public MqttServerService( MqttSettingsModel mqttSettings, @@ -127,7 +127,7 @@ namespace MQTTnet.Server.Mqtt return _mqttServer.PublishAsync(applicationMessage); } - private void Publish(PythonDictionary parameters) + void Publish(PythonDictionary parameters) { try { @@ -173,7 +173,7 @@ namespace MQTTnet.Server.Mqtt } } - private IMqttServerOptions CreateMqttServerOptions() + IMqttServerOptions CreateMqttServerOptions() { var options = new MqttServerOptionsBuilder() .WithMaxPendingMessagesPerClient(_settings.MaxPendingMessagesPerClient) diff --git a/Source/MQTTnet.Server/Program.cs b/Source/MQTTnet.Server/Program.cs index eaab8846..6ef1e948 100644 --- a/Source/MQTTnet.Server/Program.cs +++ b/Source/MQTTnet.Server/Program.cs @@ -1,8 +1,8 @@ -using System; -using System.Reflection; -using Microsoft.AspNetCore; -using Microsoft.AspNetCore.Hosting; +using Microsoft.AspNetCore.Hosting; +using Microsoft.Extensions.Hosting; using MQTTnet.Server.Web; +using System; +using System.Reflection; namespace MQTTnet.Server { @@ -14,7 +14,15 @@ namespace MQTTnet.Server { PrintLogo(); - WebHost.CreateDefaultBuilder(args).UseStartup().Build().Run(); + Host.CreateDefaultBuilder(args) + .ConfigureWebHostDefaults(webBuilder => + { + webBuilder.ConfigureKestrel(serverOptions => + { + }) + .UseStartup(); + + }).Build().Run(); return 0; } @@ -25,7 +33,7 @@ namespace MQTTnet.Server } } - private static void PrintLogo() + static void PrintLogo() { Console.ResetColor(); Console.ForegroundColor = ConsoleColor.Red; @@ -46,7 +54,7 @@ namespace MQTTnet.Server Console.WriteLine(); Console.ForegroundColor = ConsoleColor.White; Console.WriteLine("The official MQTT server implementation of MQTTnet"); - Console.WriteLine("Copyright (c) 2017-2019 The MQTTnet Team"); + Console.WriteLine("Copyright (c) 2017-2020 The MQTTnet Team"); Console.WriteLine(@"https://github.com/chkr1011/MQTTnet"); Console.ForegroundColor = ConsoleColor.White; diff --git a/Source/MQTTnet.Server/Web/Startup.cs b/Source/MQTTnet.Server/Web/Startup.cs index 2beb771e..e6952de9 100644 --- a/Source/MQTTnet.Server/Web/Startup.cs +++ b/Source/MQTTnet.Server/Web/Startup.cs @@ -1,6 +1,5 @@ using Microsoft.AspNetCore.Authentication; using Microsoft.AspNetCore.Builder; -using Microsoft.AspNetCore.Hosting; using Microsoft.AspNetCore.Mvc; using Microsoft.Extensions.Configuration; using Microsoft.Extensions.DependencyInjection; @@ -36,33 +35,27 @@ namespace MQTTnet.Server.Web public void Configure( IApplicationBuilder application, - IHostingEnvironment environment, MqttServerService mqttServerService, PythonScriptHostService pythonScriptHostService, DataSharingService dataSharingService, MqttSettingsModel mqttSettings) { - if (environment.IsDevelopment()) - { - application.UseDeveloperExceptionPage(); - } - else - { - application.UseHsts(); - } - + application.UseHsts(); + application.UseRouting(); application.UseCors(x => x .AllowAnyOrigin() .AllowAnyMethod() - .AllowAnyHeader() - .AllowCredentials()); + .AllowAnyHeader()); application.UseAuthentication(); + application.UseAuthorization(); application.UseStaticFiles(); - application.UseHttpsRedirection(); - application.UseMvc(); + application.UseEndpoints(endpoints => + { + endpoints.MapControllers(); + }); ConfigureWebSocketEndpoint(application, mqttServerService, mqttSettings); @@ -88,6 +81,9 @@ namespace MQTTnet.Server.Web { services.AddCors(); + + services.AddControllers(); + services.AddMvc() .SetCompatibilityVersion(CompatibilityVersion.Version_3_0) .AddNewtonsoftJson(o => @@ -112,12 +108,11 @@ namespace MQTTnet.Server.Web services.AddSingleton(); services.AddSingleton(); services.AddSingleton(); + services.AddSingleton(); services.AddSingleton(); services.AddSwaggerGen(c => { - c.DescribeAllEnumsAsStrings(); - var securityScheme = new OpenApiSecurityScheme { Scheme = "Basic", diff --git a/Source/MQTTnet/Diagnostics/MqttNetLogMessagePublishedEventArgs.cs b/Source/MQTTnet/Diagnostics/MqttNetLogMessagePublishedEventArgs.cs index e64a40d0..a1da8815 100644 --- a/Source/MQTTnet/Diagnostics/MqttNetLogMessagePublishedEventArgs.cs +++ b/Source/MQTTnet/Diagnostics/MqttNetLogMessagePublishedEventArgs.cs @@ -8,7 +8,9 @@ namespace MQTTnet.Diagnostics { LogMessage = logMessage ?? throw new ArgumentNullException(nameof(logMessage)); +#pragma warning disable CS0618 // Type or member is obsolete TraceMessage = logMessage ?? throw new ArgumentNullException(nameof(logMessage)); +#pragma warning restore CS0618 // Type or member is obsolete } [Obsolete("Use new proeprty LogMessage instead.")] diff --git a/Tests/MQTTnet.Core.Tests/CrossPlatformSocket_Tests.cs b/Tests/MQTTnet.Core.Tests/CrossPlatformSocket_Tests.cs index 3e3455e0..27f38e5c 100644 --- a/Tests/MQTTnet.Core.Tests/CrossPlatformSocket_Tests.cs +++ b/Tests/MQTTnet.Core.Tests/CrossPlatformSocket_Tests.cs @@ -58,7 +58,7 @@ namespace MQTTnet.Tests //} [TestMethod] - public async Task Set_Options() + public void Set_Options() { var crossPlatformSocket = new CrossPlatformSocket(); diff --git a/Tests/MQTTnet.Core.Tests/Mockups/TestLogger.cs b/Tests/MQTTnet.Core.Tests/Mockups/TestLogger.cs index e1878ed7..a9f4c299 100644 --- a/Tests/MQTTnet.Core.Tests/Mockups/TestLogger.cs +++ b/Tests/MQTTnet.Core.Tests/Mockups/TestLogger.cs @@ -34,7 +34,11 @@ namespace MQTTnet.Tests.Mockups public void Publish(MqttNetLogLevel logLevel, string message, object[] parameters, Exception exception) { - throw new NotImplementedException(); + LogMessagePublished?.Invoke(this, new MqttNetLogMessagePublishedEventArgs(new MqttNetLogMessage + { + Level = logLevel, + Message = message + })); } } }