41 lines
No EOL
931 B
C#
41 lines
No EOL
931 B
C#
using SinkyShipsAPI.Hubs;
|
|
|
|
var builder = WebApplication.CreateBuilder(args);
|
|
builder.Services.AddControllers();
|
|
builder.Services.AddEndpointsApiExplorer();
|
|
builder.Services.AddSignalR();
|
|
builder.Services.AddSwaggerGen();
|
|
builder.Services.AddCors();
|
|
|
|
var app = builder.Build();
|
|
// Configure the HTTP request pipeline.
|
|
if (app.Environment.IsDevelopment())
|
|
{
|
|
app.UseSwagger();
|
|
app.UseSwaggerUI();
|
|
app.UseCors(policyBuilder => policyBuilder
|
|
.AllowAnyHeader()
|
|
.AllowAnyMethod()
|
|
.AllowAnyOrigin()
|
|
.AllowCredentials()
|
|
);
|
|
}
|
|
app.UseHttpsRedirection();
|
|
app.UseRouting();
|
|
app.UseAuthorization();
|
|
app.UseEndpoints(endpoints =>
|
|
{
|
|
endpoints.MapHub<GameHub>("/hub");
|
|
});
|
|
|
|
app.MapGet("/", () => "Hello World!");
|
|
|
|
//Websocket functions
|
|
|
|
//SessionStart name -> sessionId
|
|
//SessionJoin sessionCode, name -> sessionId
|
|
//StartGame sessionId, settings
|
|
//SubmitBoard shipPositions[] ->
|
|
//
|
|
|
|
app.Run(); |