WIP switch to ServicePoint2 library

This commit is contained in:
Vinzenz Schroeter 2024-05-13 01:23:34 +02:00
parent eb999b0d1a
commit e1cfd714c1
31 changed files with 66 additions and 791 deletions

View file

@ -1,13 +1,13 @@
using System.IO;
using System.Text;
using System.Text.Json;
using DisplayCommands;
using Microsoft.AspNetCore.Builder;
using Microsoft.AspNetCore.Diagnostics.HealthChecks;
using Microsoft.AspNetCore.Http;
using Microsoft.AspNetCore.Http.HttpResults;
using Microsoft.AspNetCore.Mvc;
using Microsoft.Extensions.Diagnostics.HealthChecks;
using ServicePoint2;
using TanksServer.GameLogic;
using TanksServer.Interactivity;
@ -19,7 +19,7 @@ internal sealed class Endpoints(
ControlsServer controlsServer,
MapService mapService,
ChangeToRequestedMap changeToRequestedMap,
IDisplayConnection displayConnection
Connection displayConnection
)
{
public void Map(WebApplication app)
@ -31,7 +31,7 @@ internal sealed class Endpoints(
app.Map("/controls", ConnectControlsAsync);
app.MapGet("/map", () => mapService.MapNames);
app.MapPost("/map", PostMap);
app.MapPost("/resetDisplay", displayConnection.SendHardResetAsync);
app.MapPost("/resetDisplay", () => displayConnection.Send(Command.HardReset()));
app.MapGet("/map/{name}", GetMapByName);
app.MapHealthChecks("/health", new HealthCheckOptions
@ -117,7 +117,7 @@ internal sealed class Endpoints(
if (!mapService.TryGetPreview(name, out var preview))
return TypedResults.NotFound();
var mapInfo = new MapInfo(prototype.Name, prototype.GetType().Name, preview.Data);
var mapInfo = new MapInfo(prototype.Name, prototype.GetType().Name, preview.Data.ToArray());
return TypedResults.Ok(mapInfo);
}