automatic rejoin on reload or server restart
This commit is contained in:
parent
feaf96c10e
commit
64a61ef2b3
11 changed files with 141 additions and 58 deletions
|
@ -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;
|
||||
|
|
|
@ -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) =>
|
||||
|
|
Loading…
Add table
Add a link
Reference in a new issue