automatic rejoin on reload or server restart

This commit is contained in:
Vinzenz Schroeter 2024-04-13 19:50:37 +02:00
parent feaf96c10e
commit 64a61ef2b3
11 changed files with 141 additions and 58 deletions

View file

@ -5,4 +5,5 @@ namespace TanksServer.Interactivity;
[JsonSerializable(typeof(Player))]
[JsonSerializable(typeof(IEnumerable<Player>))]
[JsonSerializable(typeof(Guid))]
[JsonSerializable(typeof(NameId))]
internal sealed partial class AppSerializerContext : JsonSerializerContext;

View file

@ -11,6 +11,8 @@ using TanksServer.Interactivity;
namespace TanksServer;
internal sealed record class NameId(string Name, Guid Id);
public static class Program
{
public static void Main(string[] args)
@ -29,7 +31,7 @@ public static class Program
{
var player = playerService.GetOrAdd(name, id);
return player != null
? Results.Ok(player.Id)
? Results.Ok(new NameId(name, id))
: Results.Unauthorized();
});
app.MapGet("/player", ([FromQuery] Guid id) =>