소스 검색

Merge branch 'develop' of https://github.com/chkr1011/MQTTnet into develop

release/3.x.x
Christian Kratky 6 년 전
부모
커밋
3b104049b4
2개의 변경된 파일33개의 추가작업 그리고 5개의 파일을 삭제
  1. +15
    -0
      Source/MQTTnet.AspnetCore/AspNetMqttServerOptionsBuilder.cs
  2. +18
    -5
      Source/MQTTnet.AspnetCore/ServiceCollectionExtensions.cs

+ 15
- 0
Source/MQTTnet.AspnetCore/AspNetMqttServerOptionsBuilder.cs 파일 보기

@@ -0,0 +1,15 @@
using MQTTnet.Server;
using System;

namespace MQTTnet.AspNetCore
{
public class AspNetMqttServerOptionsBuilder : MqttServerOptionsBuilder
{
public AspNetMqttServerOptionsBuilder(IServiceProvider serviceProvider)
{
ServiceProvider = serviceProvider;
}

public IServiceProvider ServiceProvider { get; }
}
}

+ 18
- 5
Source/MQTTnet.AspnetCore/ServiceCollectionExtensions.cs 파일 보기

@@ -20,14 +20,27 @@ namespace MQTTnet.AspNetCore

return services;
}
public static IServiceCollection AddHostedMqttServer(this IServiceCollection services, Action<MqttServerOptionsBuilder> configure)
{
var builder = new MqttServerOptionsBuilder();
services.AddSingleton<IMqttServerOptions>(s => {
var builder = new MqttServerOptionsBuilder();
configure(builder);
return builder.Build();
});

configure(builder);
services.AddSingleton<IMqttServerOptions>(builder.Build());
services.AddHostedMqttServer();

return services;
}

public static IServiceCollection AddHostedMqttServerWithServices(this IServiceCollection services, Action<AspNetMqttServerOptionsBuilder> configure)
{
services.AddSingleton<IMqttServerOptions>(s => {
var builder = new AspNetMqttServerOptionsBuilder(s);
configure(builder);
return builder.Build();
});

services.AddHostedMqttServer();



불러오는 중...
취소
저장