Skip to main content

ClientMessage

Enum ClientMessage 

Source
pub enum ClientMessage {
Show 32 variants Heartbeat, RequestSync, DebugState, JoinChannelLobby { channel_id: String, guild_id: Option<String>, }, CreateCustomLobby, JoinCustomLobby { lobby_code: String, }, LeaveLobby, JoinGamePool { game_type: GameType, }, LeaveGamePool, SetSandboxConfig { config: GameConfig, }, TriggerAdventureEvent { kind: AdventureEventKind, }, 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, }, SetAutoRematch { enabled: bool, }, SetLobbyDictionary { dictionary: String, }, AdminGetGames, AdminDeleteGame { game_id: String, }, PlayerDisconnected { lobby_id: Option<String>, game_id: Option<String>, },
}
Expand description

Messages sent from client to server.

Variants§

§

Heartbeat

Keep-alive ping. Server responds with HeartbeatAck.

Should be sent every 20-30 seconds to survive proxy timeouts.

§

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

§channel_id: String

Discord channel ID

§guild_id: Option<String>

Discord guild ID (optional for DM activities)

§

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.

Fields

§lobby_code: String

6-character lobby code (case-insensitive)

§

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.

Fields

§game_type: GameType

The game type pool to join

§

LeaveGamePool

Leave the current game pool.

Returns the player to the main lobby view.

§

SetSandboxConfig

Host-only: update the live sandbox config for the current lobby. Rejected by the server if the caller is not the host or lacks the sandbox_enabled capability.

Fields

§config: GameConfig
§

TriggerAdventureEvent

Host-only: fire a random event immediately in the current custom game.

§

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

§game_id: String
§word: String

The word being submitted (for validation)

§positions: Vec<Position>

Grid positions forming the word path

§

PassTurn

Pass your turn without submitting a word.

Awards 0 points and advances to the next player.

Fields

§game_id: String
§

ShuffleBoard

Shuffle the board (costs 1 gem).

Randomizes tile positions while keeping their properties (letters, multipliers, gems stay on tiles, just positions change).

Fields

§game_id: String
§

EnterSwapMode

Enter swap mode (for UI feedback).

Broadcasts to other players that you’re considering a swap. Triggers wobble animation on their screens.

Fields

§game_id: String
§

ExitSwapMode

Exit swap mode without swapping.

Fields

§game_id: String
§

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.

Fields

§game_id: String
§row: usize
§col: usize
§new_letter: char

New letter (A-Z)

§

SpectateGame

Join a game as a spectator.

Spectators can view the game but cannot interact with it.

Fields

§game_id: String
§

JoinGame

Join an active game.

The player is added at the end of the turn order. Previous rounds count as 0 points.

Fields

§game_id: String
§

LeaveSpectator

Leave spectator mode and return to lobby view.

Fields

§game_id: String
§

LeaveGame

Legacy leave game message.

Fields

§game_id: String
§

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.

Fields

§game_id: String
§positions: Vec<Position>
§

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

Fields

§game_id: String
§

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

Fields

§game_id: String
§

TriggerRematch

Trigger early rematch start for all players.

Cancels the countdown and starts the game immediately for everyone still in the rematch pool.

Fields

§previous_game_id: String

The game that just ended (for validation)

§

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.

Fields

§previous_game_id: String

The game to leave rematch for

§

SetAutoRematch

Switch the current lobby’s auto-rematch setting. Any lobby member may send it; the server broadcasts LobbyChange::AutoRematchChanged in a LobbyDelta, and sending the current value again changes nothing.

Fields

§enabled: bool
§

SetLobbyDictionary

Switch which dictionary the current lobby’s games use. Any lobby member may send it; the server broadcasts LobbyChange::DictionaryChanged in a LobbyDelta, and sending the current value again changes nothing. Only main is ranked.

Fields

§dictionary: String
§

AdminGetGames

Request list of games (admin only).

§

AdminDeleteGame

Delete a specific game (admin only).

Fields

§game_id: String
§

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.

Fields

§lobby_id: Option<String>

The lobby the player was in (if any)

§game_id: Option<String>

The game the player was in (if any)

Implementations§

Source§

impl ClientMessage

Source

pub fn message_type(&self) -> &'static str

Get the message type as a string (for logging/debugging).

Source

pub fn requires_lobby(&self) -> bool

Check if this message requires the sender to be in a lobby.

Source

pub fn requires_active_game(&self) -> bool

Check if this message requires an active game.

Source

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

Source§

fn clone(&self) -> Self

Returns a duplicate of the value. Read more
1.0.0 (const: unstable) · Source§

fn clone_from(&mut self, source: &Self)

Performs copy-assignment from source. Read more
Source§

impl Debug for ClientMessage

Source§

fn fmt(&self, f: &mut Formatter<'_>) -> Result

Formats the value using the given formatter. Read more
Source§

impl<'de> Deserialize<'de> for ClientMessage

Source§

fn deserialize<__D>(__deserializer: __D) -> Result<Self, __D::Error>
where __D: Deserializer<'de>,

Deserialize this value from the given Serde deserializer. Read more
Source§

impl Serialize for ClientMessage

Source§

fn serialize<__S>(&self, __serializer: __S) -> Result<__S::Ok, __S::Error>
where __S: Serializer,

Serialize this value into the given Serde serializer. Read more

Auto Trait Implementations§

Blanket Implementations§

Source§

impl<T> Any for T
where T: 'static + ?Sized,

Source§

fn type_id(&self) -> TypeId

Gets the TypeId of self. Read more
Source§

impl<T> Borrow<T> for T
where T: ?Sized,

Source§

fn borrow(&self) -> &T

Immutably borrows from an owned value. Read more
Source§

impl<T> BorrowMut<T> for T
where T: ?Sized,

Source§

fn borrow_mut(&mut self) -> &mut T

Mutably borrows from an owned value. Read more
Source§

impl<T> CloneToUninit for T
where T: Clone,

Source§

unsafe fn clone_to_uninit(&self, dest: *mut u8)

🔬This is a nightly-only experimental API. (clone_to_uninit)
Performs copy-assignment from self to dest. Read more
Source§

impl<T> DeserializeOwned for T
where T: for<'de> Deserialize<'de>,

Source§

impl<T> From<T> for T

Source§

fn from(t: T) -> T

Returns the argument unchanged.

Source§

impl<T, U> Into<U> for T
where U: From<T>,

Source§

fn into(self) -> U

Calls U::from(self).

That is, this conversion is whatever the implementation of From<T> for U chooses to do.

Source§

impl<T> ToOwned for T
where T: Clone,

Source§

type Owned = T

The resulting type after obtaining ownership.
Source§

fn to_owned(&self) -> T

Creates owned data from borrowed data, usually by cloning. Read more
Source§

fn clone_into(&self, target: &mut T)

Uses borrowed data to replace owned data, usually by cloning. Read more
Source§

impl<T, U> TryFrom<U> for T
where U: Into<T>,

Source§

type Error = !

The type returned in the event of a conversion error.
Source§

fn try_from(value: U) -> Result<T, !>

Performs the conversion.
Source§

impl<T, U> TryInto<U> for T
where U: TryFrom<T>,

Source§

type Error = <U as TryFrom<T>>::Error

The type returned in the event of a conversion error.
Source§

fn try_into(self) -> Result<U, <U as TryFrom<T>>::Error>

Performs the conversion.