pub enum ClientMessage {
Show 31 variants
Identify {
resume_seq: Option<u64>,
},
Heartbeat,
Ack {
seq: u64,
},
RequestSync,
DebugState,
JoinChannelLobby {
channel_id: String,
guild_id: Option<String>,
},
CreateCustomLobby,
JoinCustomLobby {
lobby_code: String,
},
LeaveLobby,
JoinGamePool {
game_type: GameType,
},
LeaveGamePool,
CreateGame {
mode: GameMode,
},
StartGame {
config: Option<GameConfig>,
},
SubmitWord {
game_id: String,
word: String,
positions: Vec<Position>,
},
PassTurn {
game_id: String,
},
ShuffleBoard {
game_id: String,
},
EnterSwapMode {
game_id: String,
},
ExitSwapMode {
game_id: String,
},
SwapTile {
game_id: String,
row: usize,
col: usize,
new_letter: char,
},
SpectateGame {
game_id: String,
},
JoinGame {
game_id: String,
},
LeaveSpectator {
game_id: String,
},
LeaveGame {
game_id: String,
},
SelectionUpdate {
game_id: String,
positions: Vec<Position>,
},
InitiateTimerVote {
game_id: String,
},
VoteForTimer {
game_id: String,
},
TriggerRematch {
previous_game_id: String,
},
LeaveRematch {
previous_game_id: String,
},
AdminGetGames,
AdminDeleteGame {
game_id: String,
},
PlayerDisconnected {
lobby_id: Option<String>,
game_id: Option<String>,
},
}Expand description
Messages sent from client to server.
Variants§
Identify
Initial identification after WebSocket connect.
If resume_seq is provided, attempt to resume a previous session
and receive missed messages since that sequence number.
Heartbeat
Keep-alive ping. Server responds with HeartbeatAck.
Should be sent every 20-30 seconds to survive proxy timeouts.
Ack
Explicit acknowledgment of received messages.
Can be used when no other message is being sent to confirm receipt. Usually, acks are piggybacked on other messages via the envelope.
RequestSync
Request a full state sync from the server.
Used to recover from state desync between client and server.
Server responds with LobbySnapshot and optionally GameSnapshot.
DebugState
Request debug state information for diagnosing context issues.
Returns detailed information about the player’s current state in the WebSocket handler, lobby, and game systems.
JoinChannelLobby
Join a channel-based lobby (default Discord Activity behavior).
The lobby is automatically created if it doesn’t exist.
Fields
CreateCustomLobby
Create a new custom lobby with a shareable code.
Returns a 6-character code that others can use to join.
JoinCustomLobby
Join an existing custom lobby by its code.
LeaveLobby
Leave the current lobby.
If in a game, this also leaves the game.
JoinGamePool
Join a game pool within the lobby.
Players must join a game pool to be matched for that game type. Only one game pool can be joined at a time.
LeaveGamePool
Leave the current game pool.
Returns the player to the main lobby view.
CreateGame
Request to create a new game (legacy - prefer StartGame).
StartGame
Start a new game in the current lobby.
By default, any player can start. Can be restricted to host only via server configuration.
Requirements:
- Must be in a lobby
- 1-6 connected players
- No game already in progress
Fields
config: Option<GameConfig>Optional game configuration
SubmitWord
Submit a word during your turn.
The word is derived from the positions on the grid. Positions must form a valid path (adjacent cells, no repeats).
Fields
PassTurn
Pass your turn without submitting a word.
Awards 0 points and advances to the next player.
ShuffleBoard
Shuffle the board (costs 1 gem).
Randomizes tile positions while keeping their properties (letters, multipliers, gems stay on tiles, just positions change).
EnterSwapMode
Enter swap mode (for UI feedback).
Broadcasts to other players that you’re considering a swap. Triggers wobble animation on their screens.
ExitSwapMode
Exit swap mode without swapping.
SwapTile
Swap a tile’s letter (costs 3 gems).
Changes the letter on a specific tile. The multiplier and gem status of the tile are preserved.
SpectateGame
Join a game as a spectator.
Spectators can view the game but cannot interact with it.
JoinGame
Join an active game.
The player is added at the end of the turn order. Previous rounds count as 0 points.
LeaveSpectator
Leave spectator mode and return to lobby view.
LeaveGame
Legacy leave game message.
SelectionUpdate
Broadcast current tile selection to other players.
Sent as the player selects tiles, allowing spectators and other players to see the selection in real-time.
InitiateTimerVote
Initiate a vote to start a turn timer on the current player.
Requirements:
- At least 3 players in game
- Not your turn
- No vote already in progress
- Not in cooldown
VoteForTimer
Vote yes on an active timer vote.
Requirements:
- Vote must be in progress
- You haven’t already voted
- You didn’t initiate the vote
- Not your turn
TriggerRematch
Trigger early rematch start for all players.
Cancels the countdown and starts the game immediately for everyone still in the rematch pool.
LeaveRematch
Leave the rematch pool and return to lobby.
The player will be removed from the rematch player list and other players will be notified.
AdminGetGames
Request list of games (admin only).
AdminDeleteGame
Delete a specific game (admin only).
PlayerDisconnected
Player disconnected from WebSocket.
This message is generated by the backend when a WebSocket connection closes unexpectedly. It is dispatched to handlers to trigger grace period logic and schedule cleanup timers.
Not sent by clients - synthesized by the server.
Implementations§
Source§impl ClientMessage
impl ClientMessage
Sourcepub fn message_type(&self) -> &'static str
pub fn message_type(&self) -> &'static str
Get the message type as a string (for logging/debugging).
Sourcepub fn requires_lobby(&self) -> bool
pub fn requires_lobby(&self) -> bool
Check if this message requires the sender to be in a lobby.
Sourcepub fn requires_active_game(&self) -> bool
pub fn requires_active_game(&self) -> bool
Check if this message requires an active game.
Sourcepub fn requires_turn(&self) -> bool
pub fn requires_turn(&self) -> bool
Check if this message requires it to be the sender’s turn.
Trait Implementations§
Source§impl Clone for ClientMessage
impl Clone for ClientMessage
Source§fn clone(&self) -> ClientMessage
fn clone(&self) -> ClientMessage
1.0.0 · Source§fn clone_from(&mut self, source: &Self)
fn clone_from(&mut self, source: &Self)
source. Read more