Você não pode selecionar mais de 25 tópicos
Os tópicos devem começar com uma letra ou um número, podem incluir traços ('-') e podem ter até 35 caracteres.
|
- using System;
- using Microsoft.Extensions.DependencyInjection;
- using Microsoft.Extensions.Hosting;
- using MQTTnet.Adapter;
- using MQTTnet.Diagnostics;
- using MQTTnet.Server;
- using MQTTnet.Implementations;
-
- namespace MQTTnet.AspNetCore
- {
- public static class ServiceCollectionExtensions
- {
- public static IServiceCollection AddHostedMqttServer(this IServiceCollection services, IMqttServerOptions options)
- {
- if (options == null) throw new ArgumentNullException(nameof(options));
-
- services.AddSingleton(options);
- services.AddSingleton<IMqttNetLogger>(new MqttNetLogger());
- services.AddSingleton<MqttHostedServer>();
- services.AddSingleton<IHostedService>(s => s.GetService<MqttHostedServer>());
- services.AddSingleton<IMqttServer>(s => s.GetService<MqttHostedServer>());
-
- services.AddSingleton<MqttWebSocketServerAdapter>();
- services.AddSingleton<MqttTcpServerAdapter>();
- services.AddSingleton<IMqttServerAdapter>(s => s.GetService<MqttWebSocketServerAdapter>());
- services.AddSingleton<IMqttServerAdapter>(s => s.GetService<MqttTcpServerAdapter>());
-
- return services;
- }
- }
- }
|