Fix build warnings and errors.

This commit is contained in:
Christian Kratky
2020-04-04 19:40:09 +02:00
parent fc358f9015
commit 54870adc64
15 changed files with 90 additions and 57 deletions
+4
View File
@@ -8,6 +8,7 @@
<license type="file">LICENSE</license> <license type="file">LICENSE</license>
<projectUrl>https://github.com/chkr1011/MQTTnet</projectUrl> <projectUrl>https://github.com/chkr1011/MQTTnet</projectUrl>
<iconUrl>https://raw.githubusercontent.com/chkr1011/MQTTnet/master/Images/Logo_128x128.png</iconUrl> <iconUrl>https://raw.githubusercontent.com/chkr1011/MQTTnet/master/Images/Logo_128x128.png</iconUrl>
<icon>images\Logo_128x128.png</icon>
<requireLicenseAcceptance>false</requireLicenseAcceptance> <requireLicenseAcceptance>false</requireLicenseAcceptance>
<description>This is a support library to integrate MQTTnet into AspNetCore.</description> <description>This is a support library to integrate MQTTnet into AspNetCore.</description>
<releaseNotes>For release notes please go to MQTTnet release notes (https://www.nuget.org/packages/MQTTnet/).</releaseNotes> <releaseNotes>For release notes please go to MQTTnet release notes (https://www.nuget.org/packages/MQTTnet/).</releaseNotes>
@@ -27,6 +28,9 @@
<!-- License --> <!-- License -->
<file src="..\LICENSE" /> <file src="..\LICENSE" />
<!-- Images -->
<file src="..\Images\Logo_128x128.png" target="images\" />
<!-- .NET Standard 2.0 --> <!-- .NET Standard 2.0 -->
<file src="..\Source\MQTTnet.AspNetCore\bin\Release\netstandard2.0\MQTTnet.AspNetCore.*" target="lib\netstandard2.0\"/> <file src="..\Source\MQTTnet.AspNetCore\bin\Release\netstandard2.0\MQTTnet.AspNetCore.*" target="lib\netstandard2.0\"/>
</files> </files>
@@ -8,6 +8,7 @@
<license type="file">LICENSE</license> <license type="file">LICENSE</license>
<projectUrl>https://github.com/chkr1011/MQTTnet</projectUrl> <projectUrl>https://github.com/chkr1011/MQTTnet</projectUrl>
<iconUrl>https://raw.githubusercontent.com/chkr1011/MQTTnet/master/Images/Logo_128x128.png</iconUrl> <iconUrl>https://raw.githubusercontent.com/chkr1011/MQTTnet/master/Images/Logo_128x128.png</iconUrl>
<icon>images\Logo_128x128.png</icon>
<requireLicenseAcceptance>false</requireLicenseAcceptance> <requireLicenseAcceptance>false</requireLicenseAcceptance>
<description>This is an extension library which provides a managed MQTT client with additional features using MQTTnet.</description> <description>This is an extension library which provides a managed MQTT client with additional features using MQTTnet.</description>
<releaseNotes>For release notes please go to MQTTnet release notes (https://www.nuget.org/packages/MQTTnet/).</releaseNotes> <releaseNotes>For release notes please go to MQTTnet release notes (https://www.nuget.org/packages/MQTTnet/).</releaseNotes>
@@ -22,6 +23,9 @@
<!-- License --> <!-- License -->
<file src="..\LICENSE" /> <file src="..\LICENSE" />
<!-- Images -->
<file src="..\Images\Logo_128x128.png" target="images\" />
<!-- .NET Standard 1.3 --> <!-- .NET Standard 1.3 -->
<file src="..\Source\MQTTnet.Extensions.ManagedClient\bin\Release\netstandard1.3\MQTTnet.Extensions.ManagedClient.*" target="lib\netstandard1.3\"/> <file src="..\Source\MQTTnet.Extensions.ManagedClient\bin\Release\netstandard1.3\MQTTnet.Extensions.ManagedClient.*" target="lib\netstandard1.3\"/>
+4
View File
@@ -8,6 +8,7 @@
<license type="file">LICENSE</license> <license type="file">LICENSE</license>
<projectUrl>https://github.com/chkr1011/MQTTnet</projectUrl> <projectUrl>https://github.com/chkr1011/MQTTnet</projectUrl>
<iconUrl>https://raw.githubusercontent.com/chkr1011/MQTTnet/master/Images/Logo_128x128.png</iconUrl> <iconUrl>https://raw.githubusercontent.com/chkr1011/MQTTnet/master/Images/Logo_128x128.png</iconUrl>
<icon>images\Logo_128x128.png</icon>
<requireLicenseAcceptance>false</requireLicenseAcceptance> <requireLicenseAcceptance>false</requireLicenseAcceptance>
<description>This is an extension library which allows executing synchronous device calls including a response using MQTTnet.</description> <description>This is an extension library which allows executing synchronous device calls including a response using MQTTnet.</description>
<releaseNotes>For release notes please go to MQTTnet release notes (https://www.nuget.org/packages/MQTTnet/).</releaseNotes> <releaseNotes>For release notes please go to MQTTnet release notes (https://www.nuget.org/packages/MQTTnet/).</releaseNotes>
@@ -22,6 +23,9 @@
<!-- License --> <!-- License -->
<file src="..\LICENSE" /> <file src="..\LICENSE" />
<!-- Images -->
<file src="..\Images\Logo_128x128.png" target="images\" />
<!-- .NET Standard 1.3 --> <!-- .NET Standard 1.3 -->
<file src="..\Source\MQTTnet.Extensions.Rpc\bin\Release\netstandard1.3\MQTTnet.Extensions.Rpc.*" target="lib\netstandard1.3\"/> <file src="..\Source\MQTTnet.Extensions.Rpc\bin\Release\netstandard1.3\MQTTnet.Extensions.Rpc.*" target="lib\netstandard1.3\"/>
@@ -8,6 +8,7 @@
<license type="file">LICENSE</license> <license type="file">LICENSE</license>
<projectUrl>https://github.com/chkr1011/MQTTnet</projectUrl> <projectUrl>https://github.com/chkr1011/MQTTnet</projectUrl>
<iconUrl>https://raw.githubusercontent.com/chkr1011/MQTTnet/master/Images/Logo_128x128.png</iconUrl> <iconUrl>https://raw.githubusercontent.com/chkr1011/MQTTnet/master/Images/Logo_128x128.png</iconUrl>
<icon>images\Logo_128x128.png</icon>
<requireLicenseAcceptance>false</requireLicenseAcceptance> <requireLicenseAcceptance>false</requireLicenseAcceptance>
<description>This is an extension library which allows using _WebSocket4Net_ as transport for MQTTnet clients.</description> <description>This is an extension library which allows using _WebSocket4Net_ as transport for MQTTnet clients.</description>
<releaseNotes>For release notes please go to MQTTnet release notes (https://www.nuget.org/packages/MQTTnet/).</releaseNotes> <releaseNotes>For release notes please go to MQTTnet release notes (https://www.nuget.org/packages/MQTTnet/).</releaseNotes>
@@ -22,6 +23,9 @@
<!-- License --> <!-- License -->
<file src="..\LICENSE" /> <file src="..\LICENSE" />
<!-- Images -->
<file src="..\Images\Logo_128x128.png" target="images\" />
<!-- .NET Standard 1.3 --> <!-- .NET Standard 1.3 -->
<file src="..\Source\MQTTnet.Extensions.WebSocket4Net\bin\Release\netstandard1.3\MQTTnet.Extensions.WebSocket4Net.*" target="lib\netstandard1.3\"/> <file src="..\Source\MQTTnet.Extensions.WebSocket4Net\bin\Release\netstandard1.3\MQTTnet.Extensions.WebSocket4Net.*" target="lib\netstandard1.3\"/>
+4
View File
@@ -8,6 +8,7 @@
<license type="file">LICENSE</license> <license type="file">LICENSE</license>
<projectUrl>https://github.com/chkr1011/MQTTnet</projectUrl> <projectUrl>https://github.com/chkr1011/MQTTnet</projectUrl>
<iconUrl>https://raw.githubusercontent.com/chkr1011/MQTTnet/master/Images/Logo_128x128.png</iconUrl> <iconUrl>https://raw.githubusercontent.com/chkr1011/MQTTnet/master/Images/Logo_128x128.png</iconUrl>
<icon>images\Logo_128x128.png</icon>
<requireLicenseAcceptance>false</requireLicenseAcceptance> <requireLicenseAcceptance>false</requireLicenseAcceptance>
<description>This package contains the .NET Standard version of MQTTnet only.</description> <description>This package contains the .NET Standard version of MQTTnet only.</description>
<releaseNotes>For release notes please go to MQTTnet release notes (https://www.nuget.org/packages/MQTTnet/).</releaseNotes> <releaseNotes>For release notes please go to MQTTnet release notes (https://www.nuget.org/packages/MQTTnet/).</releaseNotes>
@@ -33,6 +34,9 @@
<!-- License --> <!-- License -->
<file src="..\LICENSE" /> <file src="..\LICENSE" />
<!-- Images -->
<file src="..\Images\Logo_128x128.png" target="images\" />
<!-- .NET Standard 1.3 --> <!-- .NET Standard 1.3 -->
<file src="..\Source\MQTTnet\bin\Release\netstandard1.3\MQTTnet.*" target="lib\netstandard1.3\"/> <file src="..\Source\MQTTnet\bin\Release\netstandard1.3\MQTTnet.*" target="lib\netstandard1.3\"/>
+4
View File
@@ -8,6 +8,7 @@
<license type="file">LICENSE</license> <license type="file">LICENSE</license>
<projectUrl>https://github.com/chkr1011/MQTTnet</projectUrl> <projectUrl>https://github.com/chkr1011/MQTTnet</projectUrl>
<iconUrl>https://raw.githubusercontent.com/chkr1011/MQTTnet/master/Images/Logo_128x128.png</iconUrl> <iconUrl>https://raw.githubusercontent.com/chkr1011/MQTTnet/master/Images/Logo_128x128.png</iconUrl>
<icon>images\Logo_128x128.png</icon>
<requireLicenseAcceptance>false</requireLicenseAcceptance> <requireLicenseAcceptance>false</requireLicenseAcceptance>
<description>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.</description> <description>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.</description>
<releaseNotes> <releaseNotes>
@@ -55,6 +56,9 @@
<!-- License --> <!-- License -->
<file src="..\LICENSE" /> <file src="..\LICENSE" />
<!-- Images -->
<file src="..\Images\Logo_128x128.png" target="images\" />
<!-- .NET Standard 1.3 --> <!-- .NET Standard 1.3 -->
<file src="..\Source\MQTTnet\bin\Release\netstandard1.3\MQTTnet.*" target="lib\netstandard1.3\"/> <file src="..\Source\MQTTnet\bin\Release\netstandard1.3\MQTTnet.*" target="lib\netstandard1.3\"/>
+8 -8
View File
@@ -84,8 +84,8 @@ Remove-Item "nuget.exe" -Force -Recurse -ErrorAction SilentlyContinue
# Build MQTTnet.Server Portable # Build MQTTnet.Server Portable
&dotnet publish ..\Source\MQTTnet.Server\MQTTnet.Server.csproj --configuration Release /p:FileVersion=$assemblyVersion /p:Version=$nugetVersion &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" $source = (Convert-Path .) + "\..\Source\MQTTnet.Server\bin\Release\netcoreapp3.1\publish"
$destination = "..\Source\MQTTnet.Server\bin\MQTTnet.Server-Portable-v$nugetVersion.zip" $destination = (Convert-Path .) + "\..\Source\MQTTnet.Server\bin\MQTTnet.Server-Portable-v$nugetVersion.zip"
If(Test-path $destination) {Remove-item $destination} If(Test-path $destination) {Remove-item $destination}
Add-Type -assembly "system.io.compression.filesystem" Add-Type -assembly "system.io.compression.filesystem"
[io.compression.zipfile]::CreateFromDirectory($source, $destination) [io.compression.zipfile]::CreateFromDirectory($source, $destination)
@@ -95,8 +95,8 @@ If(Test-path $destination) {Remove-item $destination}
# Build MQTTnet.Server Linux-x64 # 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 &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" $source = (Convert-Path .) + "\..\Source\MQTTnet.Server\bin\Release\netcoreapp3.1\linux-x64\publish"
$destination = "..\Source\MQTTnet.Server\bin\MQTTnet.Server-Linux-x64-v$nugetVersion.zip" $destination = (Convert-Path .) + "\..\Source\MQTTnet.Server\bin\MQTTnet.Server-Linux-x64-v$nugetVersion.zip"
If(Test-path $destination) {Remove-item $destination} If(Test-path $destination) {Remove-item $destination}
Add-Type -assembly "system.io.compression.filesystem" Add-Type -assembly "system.io.compression.filesystem"
[io.compression.zipfile]::CreateFromDirectory($source, $destination) [io.compression.zipfile]::CreateFromDirectory($source, $destination)
@@ -106,8 +106,8 @@ If(Test-path $destination) {Remove-item $destination}
# Build MQTTnet.Server Linux-ARM # 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 &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" $source = (Convert-Path .) + "\..\Source\MQTTnet.Server\bin\Release\netcoreapp3.1\linux-ARM\publish"
$destination = "..\Source\MQTTnet.Server\bin\MQTTnet.Server-Linux-ARM-v$nugetVersion.zip" $destination = (Convert-Path .) + "\..\Source\MQTTnet.Server\bin\MQTTnet.Server-Linux-ARM-v$nugetVersion.zip"
If(Test-path $destination) {Remove-item $destination} If(Test-path $destination) {Remove-item $destination}
Add-Type -assembly "system.io.compression.filesystem" Add-Type -assembly "system.io.compression.filesystem"
[io.compression.zipfile]::CreateFromDirectory($source, $destination) [io.compression.zipfile]::CreateFromDirectory($source, $destination)
@@ -117,8 +117,8 @@ If(Test-path $destination) {Remove-item $destination}
# Build MQTTnet.Server Windows-x64 # 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 &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" $source = (Convert-Path .) + "\..\Source\MQTTnet.Server\bin\Release\netcoreapp3.1\win-x64\publish"
$destination = "..\Source\MQTTnet.Server\bin\MQTTnet.Server-Windows-x64-v$nugetVersion.zip" $destination = (Convert-Path .) + "\..\Source\MQTTnet.Server\bin\MQTTnet.Server-Windows-x64-v$nugetVersion.zip"
If(Test-path $destination) {Remove-item $destination} If(Test-path $destination) {Remove-item $destination}
Add-Type -assembly "system.io.compression.filesystem" Add-Type -assembly "system.io.compression.filesystem"
[io.compression.zipfile]::CreateFromDirectory($source, $destination) [io.compression.zipfile]::CreateFromDirectory($source, $destination)
+2 -2
View File
@@ -1,9 +1,9 @@
# Import codeSigningKey.pfx # 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: 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. The container name may be different.
# Check if the assembly has a strong name # Check if the assembly has a strong name
> sn -vf MQTTnet.dll sn -vf MQTTnet.dll
@@ -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.Collections.Generic;
using System.IO; using System.IO;
using System.IO.Pipelines; using System.IO.Pipelines;
using System.Net; using System.Net;
using System.Net.Sockets; using System.Net.Sockets;
using System.Threading.Tasks; using System.Threading.Tasks;
using Microsoft.AspNetCore.Connections;
using Microsoft.AspNetCore.Http.Features;
using MQTTnet.Exceptions;
namespace MQTTnet.AspNetCore.Client.Tcp namespace MQTTnet.AspNetCore.Client.Tcp
{ {
@@ -43,7 +43,7 @@ namespace MQTTnet.AspNetCore.Client.Tcp
#if NETCOREAPP3_1 #if NETCOREAPP3_1
public override ValueTask DisposeAsync() public override ValueTask DisposeAsync()
#else #else
public Task DisposeAsync() public new Task DisposeAsync()
#endif #endif
{ {
IsConnected = false; IsConnected = false;
+16 -16
View File
@@ -21,21 +21,21 @@ namespace MQTTnet.Server.Mqtt
{ {
public class MqttServerService public class MqttServerService
{ {
private readonly ILogger<MqttServerService> _logger; readonly ILogger<MqttServerService> _logger;
private readonly MqttSettingsModel _settings; readonly MqttSettingsModel _settings;
private readonly MqttApplicationMessageInterceptor _mqttApplicationMessageInterceptor; readonly MqttApplicationMessageInterceptor _mqttApplicationMessageInterceptor;
private readonly MqttServerStorage _mqttServerStorage; readonly MqttServerStorage _mqttServerStorage;
private readonly MqttClientConnectedHandler _mqttClientConnectedHandler; readonly MqttClientConnectedHandler _mqttClientConnectedHandler;
private readonly MqttClientDisconnectedHandler _mqttClientDisconnectedHandler; readonly MqttClientDisconnectedHandler _mqttClientDisconnectedHandler;
private readonly MqttClientSubscribedTopicHandler _mqttClientSubscribedTopicHandler; readonly MqttClientSubscribedTopicHandler _mqttClientSubscribedTopicHandler;
private readonly MqttClientUnsubscribedTopicHandler _mqttClientUnsubscribedTopicHandler; readonly MqttClientUnsubscribedTopicHandler _mqttClientUnsubscribedTopicHandler;
private readonly MqttServerConnectionValidator _mqttConnectionValidator; readonly MqttServerConnectionValidator _mqttConnectionValidator;
private readonly IMqttServer _mqttServer; readonly IMqttServer _mqttServer;
private readonly MqttSubscriptionInterceptor _mqttSubscriptionInterceptor; readonly MqttSubscriptionInterceptor _mqttSubscriptionInterceptor;
private readonly MqttUnsubscriptionInterceptor _mqttUnsubscriptionInterceptor; readonly MqttUnsubscriptionInterceptor _mqttUnsubscriptionInterceptor;
private readonly PythonScriptHostService _pythonScriptHostService; readonly PythonScriptHostService _pythonScriptHostService;
private readonly MqttWebSocketServerAdapter _webSocketServerAdapter; readonly MqttWebSocketServerAdapter _webSocketServerAdapter;
public MqttServerService( public MqttServerService(
MqttSettingsModel mqttSettings, MqttSettingsModel mqttSettings,
@@ -127,7 +127,7 @@ namespace MQTTnet.Server.Mqtt
return _mqttServer.PublishAsync(applicationMessage); return _mqttServer.PublishAsync(applicationMessage);
} }
private void Publish(PythonDictionary parameters) void Publish(PythonDictionary parameters)
{ {
try try
{ {
@@ -173,7 +173,7 @@ namespace MQTTnet.Server.Mqtt
} }
} }
private IMqttServerOptions CreateMqttServerOptions() IMqttServerOptions CreateMqttServerOptions()
{ {
var options = new MqttServerOptionsBuilder() var options = new MqttServerOptionsBuilder()
.WithMaxPendingMessagesPerClient(_settings.MaxPendingMessagesPerClient) .WithMaxPendingMessagesPerClient(_settings.MaxPendingMessagesPerClient)
+15 -7
View File
@@ -1,8 +1,8 @@
using System; using Microsoft.AspNetCore.Hosting;
using System.Reflection; using Microsoft.Extensions.Hosting;
using Microsoft.AspNetCore;
using Microsoft.AspNetCore.Hosting;
using MQTTnet.Server.Web; using MQTTnet.Server.Web;
using System;
using System.Reflection;
namespace MQTTnet.Server namespace MQTTnet.Server
{ {
@@ -14,7 +14,15 @@ namespace MQTTnet.Server
{ {
PrintLogo(); PrintLogo();
WebHost.CreateDefaultBuilder(args).UseStartup<Startup>().Build().Run(); Host.CreateDefaultBuilder(args)
.ConfigureWebHostDefaults(webBuilder =>
{
webBuilder.ConfigureKestrel(serverOptions =>
{
})
.UseStartup<Startup>();
}).Build().Run();
return 0; return 0;
} }
@@ -25,7 +33,7 @@ namespace MQTTnet.Server
} }
} }
private static void PrintLogo() static void PrintLogo()
{ {
Console.ResetColor(); Console.ResetColor();
Console.ForegroundColor = ConsoleColor.Red; Console.ForegroundColor = ConsoleColor.Red;
@@ -46,7 +54,7 @@ namespace MQTTnet.Server
Console.WriteLine(); Console.WriteLine();
Console.ForegroundColor = ConsoleColor.White; Console.ForegroundColor = ConsoleColor.White;
Console.WriteLine("The official MQTT server implementation of MQTTnet"); 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.WriteLine(@"https://github.com/chkr1011/MQTTnet");
Console.ForegroundColor = ConsoleColor.White; Console.ForegroundColor = ConsoleColor.White;
+12 -17
View File
@@ -1,6 +1,5 @@
using Microsoft.AspNetCore.Authentication; using Microsoft.AspNetCore.Authentication;
using Microsoft.AspNetCore.Builder; using Microsoft.AspNetCore.Builder;
using Microsoft.AspNetCore.Hosting;
using Microsoft.AspNetCore.Mvc; using Microsoft.AspNetCore.Mvc;
using Microsoft.Extensions.Configuration; using Microsoft.Extensions.Configuration;
using Microsoft.Extensions.DependencyInjection; using Microsoft.Extensions.DependencyInjection;
@@ -36,33 +35,27 @@ namespace MQTTnet.Server.Web
public void Configure( public void Configure(
IApplicationBuilder application, IApplicationBuilder application,
IHostingEnvironment environment,
MqttServerService mqttServerService, MqttServerService mqttServerService,
PythonScriptHostService pythonScriptHostService, PythonScriptHostService pythonScriptHostService,
DataSharingService dataSharingService, DataSharingService dataSharingService,
MqttSettingsModel mqttSettings) MqttSettingsModel mqttSettings)
{ {
if (environment.IsDevelopment()) application.UseHsts();
{ application.UseRouting();
application.UseDeveloperExceptionPage();
}
else
{
application.UseHsts();
}
application.UseCors(x => x application.UseCors(x => x
.AllowAnyOrigin() .AllowAnyOrigin()
.AllowAnyMethod() .AllowAnyMethod()
.AllowAnyHeader() .AllowAnyHeader());
.AllowCredentials());
application.UseAuthentication(); application.UseAuthentication();
application.UseAuthorization();
application.UseStaticFiles(); application.UseStaticFiles();
application.UseHttpsRedirection(); application.UseEndpoints(endpoints =>
application.UseMvc(); {
endpoints.MapControllers();
});
ConfigureWebSocketEndpoint(application, mqttServerService, mqttSettings); ConfigureWebSocketEndpoint(application, mqttServerService, mqttSettings);
@@ -88,6 +81,9 @@ namespace MQTTnet.Server.Web
{ {
services.AddCors(); services.AddCors();
services.AddControllers();
services.AddMvc() services.AddMvc()
.SetCompatibilityVersion(CompatibilityVersion.Version_3_0) .SetCompatibilityVersion(CompatibilityVersion.Version_3_0)
.AddNewtonsoftJson(o => .AddNewtonsoftJson(o =>
@@ -112,12 +108,11 @@ namespace MQTTnet.Server.Web
services.AddSingleton<MqttClientUnsubscribedTopicHandler>(); services.AddSingleton<MqttClientUnsubscribedTopicHandler>();
services.AddSingleton<MqttServerConnectionValidator>(); services.AddSingleton<MqttServerConnectionValidator>();
services.AddSingleton<MqttSubscriptionInterceptor>(); services.AddSingleton<MqttSubscriptionInterceptor>();
services.AddSingleton<MqttUnsubscriptionInterceptor>();
services.AddSingleton<MqttApplicationMessageInterceptor>(); services.AddSingleton<MqttApplicationMessageInterceptor>();
services.AddSwaggerGen(c => services.AddSwaggerGen(c =>
{ {
c.DescribeAllEnumsAsStrings();
var securityScheme = new OpenApiSecurityScheme var securityScheme = new OpenApiSecurityScheme
{ {
Scheme = "Basic", Scheme = "Basic",
@@ -8,7 +8,9 @@ namespace MQTTnet.Diagnostics
{ {
LogMessage = logMessage ?? throw new ArgumentNullException(nameof(logMessage)); LogMessage = logMessage ?? throw new ArgumentNullException(nameof(logMessage));
#pragma warning disable CS0618 // Type or member is obsolete
TraceMessage = logMessage ?? throw new ArgumentNullException(nameof(logMessage)); TraceMessage = logMessage ?? throw new ArgumentNullException(nameof(logMessage));
#pragma warning restore CS0618 // Type or member is obsolete
} }
[Obsolete("Use new proeprty LogMessage instead.")] [Obsolete("Use new proeprty LogMessage instead.")]
@@ -58,7 +58,7 @@ namespace MQTTnet.Tests
//} //}
[TestMethod] [TestMethod]
public async Task Set_Options() public void Set_Options()
{ {
var crossPlatformSocket = new CrossPlatformSocket(); var crossPlatformSocket = new CrossPlatformSocket();
@@ -34,7 +34,11 @@ namespace MQTTnet.Tests.Mockups
public void Publish(MqttNetLogLevel logLevel, string message, object[] parameters, Exception exception) 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
}));
} }
} }
} }