feat(api): add game:ready message for client state sync

- WsGameReadySchema added to shared schemas and WsClientMessageSchema
- handleGameReady sends current game:question directly to requesting
  client socket (not broadcast) — foundation for reconnection slice
- router dispatches game:ready to handleGameReady handler
This commit is contained in:
lila 2026-04-18 09:54:31 +02:00
parent 4d4715b4ee
commit 6975384751
3 changed files with 38 additions and 2 deletions

View file

@ -52,6 +52,12 @@ export const WsLobbyStartSchema = z.object({
export type WsLobbyStart = z.infer<typeof WsLobbyStartSchema>;
export const WsGameReadySchema = z.object({
type: z.literal("game:ready"),
lobbyId: z.uuid(),
});
export type WsGameReady = z.infer<typeof WsGameReadySchema>;
export const WsGameAnswerSchema = z.object({
type: z.literal("game:answer"),
lobbyId: z.uuid(),
@ -66,6 +72,7 @@ export const WsClientMessageSchema = z.discriminatedUnion("type", [
WsLobbyLeaveSchema,
WsLobbyStartSchema,
WsGameAnswerSchema,
WsGameReadySchema,
]);
export type WsClientMessage = z.infer<typeof WsClientMessageSchema>;