Move events to server level instead of options.

This commit is contained in:
Christian
2021-10-27 22:01:45 +02:00
parent 7297336786
commit d411aa4f97
109 changed files with 1148 additions and 2096 deletions
+3 -5
View File
@@ -7,10 +7,8 @@ using Microsoft.AspNetCore.Builder;
using Microsoft.AspNetCore.Hosting;
using Microsoft.Extensions.DependencyInjection;
using Microsoft.Extensions.FileProviders;
using Microsoft.Extensions.Logging;
using MQTTnet.AspNetCore;
using MQTTnet.AspNetCore.Extensions;
using MQTTnet.Server;
namespace MQTTnet.TestApp.AspNetCore2
{
@@ -44,7 +42,7 @@ namespace MQTTnet.TestApp.AspNetCore2
app.UseMqttServer(server =>
{
server.StartedHandler = new MqttServerStartedHandlerDelegate(async args =>
server.StartedAsync += async args =>
{
var frameworkName = GetType().Assembly.GetCustomAttribute<TargetFrameworkAttribute>()?
.FrameworkName;
@@ -57,7 +55,7 @@ namespace MQTTnet.TestApp.AspNetCore2
{
try
{
await server.PublishAsync(msg.Build());
await server.PublishAsync("server", msg.Build());
msg.WithPayload($"Mqtt hosted on {frameworkName} is still awesome at {DateTime.Now}");
}
catch (Exception e)
@@ -69,7 +67,7 @@ namespace MQTTnet.TestApp.AspNetCore2
await Task.Delay(TimeSpan.FromSeconds(2));
}
}
});
};
});
app.Use((context, next) =>