diff --git a/Program.cs b/Program.cs index 99ed600..7f1a423 100644 --- a/Program.cs +++ b/Program.cs @@ -12,15 +12,42 @@ .AddJsonFile("appsettings.json", optional: false, reloadOnChange: true) .AddUserSecrets(optional: true) .AddEnvironmentVariables(); + +// Add services to the container. + builder.Services.AddSignalR(); -builder.Services.AddMemoryCache(); +//builder.Services.AddCors(); +//builder.Services.AddControllers(); +//// Learn more about configuring Swagger/OpenAPI at https://aka.ms/aspnetcore/swashbuckle +//builder.Services.AddEndpointsApiExplorer(); +//builder.Services.AddSwaggerGen(); + +builder.Services.Add(ServiceDescriptor.Singleton()); builder.Services.AddSingleton(); var app = builder.Build(); -// Preload SignalR hubs by making a dummy connection during startup -var hubContext = app.Services.GetService>(); -await hubContext.Clients.All.SendAsync("preload"); +// Configure the HTTP request pipeline. +//if (app.Environment.IsDevelopment()) +//{ +// app.UseSwagger(); +// app.UseSwaggerUI(); +//} + +//app.UseHttpsRedirection(); + +//app.UseAuthorization(); + +//app.MapControllers(); + +//app.Run(); + +//app.UseCors(builder => +//{ +// builder.WithOrigins(origins: environmentSettings.AllowedCorsOrigins ?? []); +// builder.AllowAnyHeader(); +// builder.AllowAnyMethod(); +//}); app.UseHttpsRedirection(); app.UseRouting(); @@ -32,10 +59,11 @@ (HttpContext context, GroupService groupService) => groupService.GetConnectionsByGroup(context.Request.Query["groupName"]) ); -app.MapGet("/healthcheck", () => "1"); + app.Run(); + public class BeepHub : Hub { private readonly GroupService _groupService; @@ -45,6 +73,7 @@ public BeepHub(GroupService groupService) _groupService = groupService; } + public async Task Play(string freqInKhz, string durationInSeconds, string groupName) { Console.WriteLine("Play - freqInKhz=" + freqInKhz + ", durationInSeconds:" + durationInSeconds + ", group:" + groupName); diff --git a/remote-beep-backend.csproj b/remote-beep-backend.csproj index 61777f6..0416b9b 100644 --- a/remote-beep-backend.csproj +++ b/remote-beep-backend.csproj @@ -7,12 +7,6 @@ - - true - true - true - -