using Microsoft.Extensions.DependencyInjection; using Microsoft.Extensions.Hosting; using MQTTnet.Core.Adapter; using MQTTnet.Core.Server; namespace MQTTnet.AspNetCore { public static class ServiceCollectionExtensions { public static IServiceCollection AddHostedMqttServer(this IServiceCollection services) { services.AddMqttServerServices(); services.AddSingleton(s => s.GetService()); services.AddSingleton(s => s.GetService()); services.AddSingleton(); services.AddSingleton(); services.AddSingleton(s => s.GetService()); return services; } } }