Skip to main content

Game Room

The game room namespace is the socket.io instance that handles all game room events. This includes matchmaking and the pre-game lobby.

These are the Server-to-Client events (see in the code):

interface GameRoomServerToClientEvents {
/** Tell other clients all users in the room */
usersInRoom: (
users: { userId: string; username: string; isReady: boolean; selectedDeck?: string }[]
) => void;
/** Inform clients that a game is about to start */
startGame: (gameId: string) => void;
}

These are the Client-to-Server events (see in the code):

interface GameRoomClientToServerEvents {
/** Join a room with players who are searching a game too */
joinRoom: (roomId: string, ack: (success: boolean) => void) => void;
/** Selects the deck for the player with which he will play */
selectDeck: (deckId: string, ack: (success: boolean) => void) => void;
/** Set the player ready to start state */
setReadyForGame: (isReady: boolean, ack: (success: boolean) => void) => void;
}

<code references>