mirror of
https://github.com/dotnet/MQTTnet.git
synced 2026-10-16 01:03:01 +08:00
26 lines
872 B
C#
26 lines
872 B
C#
using Microsoft.Extensions.DependencyInjection;
|
|
using Microsoft.Extensions.Hosting;
|
|
using MQTTnet.AspNetCore;
|
|
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<IHostedService>(s => s.GetService<MqttHostedServer>());
|
|
services.AddSingleton<IMqttServer>(s => s.GetService<MqttHostedServer>());
|
|
services.AddSingleton<MqttHostedServer>();
|
|
|
|
services.AddSingleton<MqttWebSocketServerAdapter>();
|
|
services.AddSingleton<IMqttServerAdapter>(s => s.GetService<MqttWebSocketServerAdapter>());
|
|
|
|
return services;
|
|
}
|
|
}
|
|
}
|