12345678910111213141516171819202122232425262728293031323334353637383940414243444546474849505152535455565758 |
- using Microsoft.AspNetCore.Builder;
- using Microsoft.AspNetCore.Hosting;
- using Microsoft.Extensions.Configuration;
- using Microsoft.Extensions.DependencyInjection;
- using Microsoft.Extensions.Hosting;
- using Microsoft.AspNetCore.WebSockets;
- using System;
- using gameapi.Controllers;
- namespace gameapi
- {
- public class Startup
- {
- public Startup(IConfiguration configuration)
- {
- Configuration = configuration;
- }
- public IConfiguration Configuration { get; }
- public void ConfigureServices(IServiceCollection services)
- {
- services.AddControllers();
- services.AddWebSockets(options =>
- {
- options.ReceiveBufferSize = 4 * 1024;
- options.KeepAliveInterval = TimeSpan.FromSeconds(120);
- });
- services.AddTransient<WebsocketController>();
- services.AddHostedService<TickController>();
- }
- public void Configure(IApplicationBuilder app, IWebHostEnvironment env)
- {
- if (env.IsDevelopment())
- {
- app.UseDeveloperExceptionPage();
- }
- app.UseRouting();
- app.UseDefaultFiles();
- app.UseStaticFiles();
- app.UseEndpoints(endpoints =>
- {
- endpoints.MapControllers();
- });
- app.UseWebSockets();
- app.UseMiddleware<WebsocketController>();
- Library.GlobalConfiguration.Set(Configuration);
- }
- }
- }
|