1889 no service for type mqttnetservermqttserver has been registered (#1892)

* Add missing service to service collection

* Update ReleaseNotes.md

* Restore service registrations
This commit is contained in:
Christian
2023-12-08 18:01:19 +01:00
committed by GitHub
parent 4df06980a1
commit eb25500f50
3 changed files with 5 additions and 1 deletions
@@ -5,6 +5,7 @@
using System;
using Microsoft.Extensions.DependencyInjection;
using Microsoft.Extensions.DependencyInjection.Extensions;
using Microsoft.Extensions.Hosting;
using MQTTnet.Adapter;
using MQTTnet.Diagnostics;
using MQTTnet.Implementations;
@@ -58,7 +59,8 @@ namespace MQTTnet.AspNetCore
services.TryAddSingleton(new MqttFactory());
services.AddSingleton<MqttHostedServer>();
services.AddHostedService<MqttHostedServer>();
services.AddSingleton<IHostedService>(s => s.GetService<MqttHostedServer>());
services.AddSingleton<MqttServer>(s => s.GetService<MqttHostedServer>());
}
public static IServiceCollection AddHostedMqttServerWithServices(this IServiceCollection services, Action<AspNetMqttServerOptionsBuilder> configure)