added aspnetcore package and adapted sample app

This commit is contained in:
Jan Eggers
2017-10-24 12:45:14 +02:00
parent 3529724bdc
commit 1ca9b0bd62
15 changed files with 260 additions and 41 deletions
@@ -0,0 +1,25 @@
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;
}
}
}