Rework sync procedure and add a loading indicator

The server will now send a sync message when the client connects via WebSocket. This removes the need to send another GET request to sync game data.
This commit is contained in:
Andrio Celos
2022-10-25 12:08:18 +11:00
parent 3ad1877a4c
commit d4e8d86571
14 changed files with 552 additions and 384 deletions

View File

@@ -8,6 +8,8 @@ using System.Web;
using Newtonsoft.Json;
using TableturfBattleServer.DTO;
using WebSocketSharp.Server;
using HttpListenerRequest = WebSocketSharp.Net.HttpListenerRequest;
@@ -154,7 +156,7 @@ internal class Program {
SetResponse(e.Response, (int) HttpStatusCode.OK, "application/json", JsonConvert.SerializeObject(new {
game,
playerData = game.GetPlayer(clientToken, out var playerIndex, out var player)
? new { playerIndex, hand = player.Hand, deck = player.Deck, cardsUsed = player.CardsUsed, move = player.Move }
? new PlayerData(playerIndex, player)
: null
}));
break;