예제 #1
0
 public static OicHostBuilder UseCoapUdp(this OicHostBuilder builder)
 {
     return(builder.ConfigureServices(services =>
                                      services
                                      .AddSingleton <ICoapTransportFactory, CoapUdpTransportFactory>()
                                      ));
 }
예제 #2
0
 public static OicHostBuilder UseCoap(this OicHostBuilder builder, Action <OicCoapServerOptions> options)
 {
     return(builder.UseCoap().ConfigureServices(services =>
     {
         services.Configure(options);
     }));
 }
예제 #3
0
        static void Main(string[] args)
        {
            var config = new ConfigurationBuilder()
                         .AddCommandLine(args)
                         .Build();


            var host = new OicHostBuilder()
                       .UseConfiguration(config)
                       .ConfigureLogging(logging =>
            {
                logging
                .AddDebug()
                .AddConsole();
            })
                       .UseCoap(options =>
            {
                // TODO: Allow providing listening options from IOptions<OicCoapServer>
                options.Listen(new CoapUdpEndPoint(Coap.Port)
                {
                    JoinMulticast = true
                });

                // enable /.well-know/core
                options.UseCoreLink = true;
            })
                       .UseCoapUdp()
                       .UseStartup <Startup>()
                       .Build();

            host.Run();
        }
예제 #4
0
 public static OicHostBuilder UseCoap(this OicHostBuilder builder)
 {
     return(builder.ConfigureServices(services =>
                                      services
                                      .AddTransient <IConfigureOptions <OicCoapServerOptions>, OicCoapServerOptionsSetup>()
                                      .AddTransient <IOicContextFactory, OicCoapContextFactory>()
                                      .AddSingleton <IOicServer, OicCoapServer>()
                                      ));
 }