Esempio n. 1
0
        // This method gets called by the runtime. Use this method to configure the HTTP request pipeline.
        public async void Configure(IApplicationBuilder app, IHostingEnvironment env,
                                    IApplicationLifetime applicationLifetime, IServiceProvider serviceProvider)
        {
            var logger = serviceProvider.GetService <ILogger <Startup> >();

            applicationLifetime.ApplicationStopping.Register(async() =>
                                                             await _servicesManager.Stop());

            if (env.IsDevelopment())
            {
                app.UseDeveloperExceptionPage();
            }
            else
            {
                // The default HSTS value is 30 days. You may want to change this for production scenarios, see https://aka.ms/aspnetcore-hsts.
                app.UseHsts();
            }

            app.UseHttpsRedirection();

            app.UseSwagger();

            app.UseCors(x => x
                        .AllowAnyOrigin()
                        .AllowAnyMethod()
                        .AllowAnyHeader());
            app.UseAuthentication();


            app.UseWebSockets();

            AssemblyUtils.ScanAllAssembliesFromAttribute(typeof(WebSocketHubAttribute)).ForEach(t =>
            {
                var wsAttr = t.GetCustomAttribute <WebSocketHubAttribute>();
                logger.LogInformation($"Registering websocket path {wsAttr.Path} to {t.Name}");

                app.MapWebSocketManager(wsAttr.Path, _container.Resolve(t) as WebSocketHandler);
            });


            if (_neonConfig.EnableSwagger)
            {
                app.UseSwaggerUI(c => { c.SwaggerEndpoint("/swagger/v1/swagger.json", "Leon Home control"); });
            }

            app.UseResponseCompression();

            app.UseMvc();
            await _servicesManager.Start();
        }
Esempio n. 2
0
        // This method gets called by the runtime. Use this method to configure the HTTP request pipeline.
        public async void Configure(IApplicationBuilder app, IHostingEnvironment env,
                                    IApplicationLifetime applicationLifetime, IServiceProvider serviceProvider)
        {
            applicationLifetime.ApplicationStopping.Register(async() =>
                                                             await _servicesManager.Stop());

            if (env.IsDevelopment())
            {
                app.UseDeveloperExceptionPage();
            }
            else
            {
                // The default HSTS value is 30 days. You may want to change this for production scenarios, see https://aka.ms/aspnetcore-hsts.
                app.UseHsts();
            }

            app.UseHttpsRedirection();

            app.UseSwagger();

            app.UseCors(x => x
                        .AllowAnyOrigin()
                        .AllowAnyMethod()
                        .AllowAnyHeader());
            app.UseAuthentication();


            app.UseWebSockets();
            app.MapWebSocketManager("/ws/events", _container.Resolve <EventsHub>());
            app.MapWebSocketManager("/ws/logs", _container.Resolve <LoggerHub>());

            if (_neonConfig.EnableSwagger)
            {
                app.UseSwaggerUI(c => { c.SwaggerEndpoint("/swagger/v1/swagger.json", "Leon Home control"); });
            }

            app.UseResponseCompression();

            app.UseMvc();
            await _servicesManager.Start();
        }
Esempio n. 3
0
 public async Task Start()
 {
     await _servicesManager.Start();
 }