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:
parent
4d4715b4ee
commit
6975384751
3 changed files with 38 additions and 2 deletions
|
|
@ -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>;
|
||||
|
||||
|
|
|
|||
Loading…
Add table
Add a link
Reference in a new issue