pub enum ClientMessage {
Authenticate {
app_id: String,
sdk_version: Option<String>,
platform: Option<String>,
game_data_format: Option<GameDataEncoding>,
},
JoinRoom {
game_name: String,
room_code: Option<String>,
player_name: String,
max_players: Option<u8>,
supports_authority: Option<bool>,
relay_transport: Option<RelayTransport>,
},
LeaveRoom,
GameData {
data: Value,
},
AuthorityRequest {
become_authority: bool,
},
PlayerReady,
ProvideConnectionInfo {
connection_info: ConnectionInfo,
},
Ping,
Reconnect {
player_id: PlayerId,
room_id: RoomId,
auth_token: String,
},
JoinAsSpectator {
game_name: String,
room_code: String,
spectator_name: String,
},
LeaveSpectator,
}Expand description
Message types sent from client to server.
Variants§
Authenticate
Authenticate with App ID (MUST be first message). App ID is a public identifier (not a secret!) that identifies the game application.
Fields
§
game_data_format: Option<GameDataEncoding>Preferred game data encoding (defaults to JSON text frames).
JoinRoom
Join or create a room for a specific game.
Fields
§
relay_transport: Option<RelayTransport>Preferred relay transport protocol (TCP, UDP, or Auto). If not specified, defaults to Auto.
LeaveRoom
Leave the current room.
GameData
Send game data to other players in the room.
AuthorityRequest
Request to become or connect to authoritative server.
Fields
PlayerReady
Signal readiness to start the game in lobby.
ProvideConnectionInfo
Provide connection info for P2P establishment.
Fields
§
connection_info: ConnectionInfoPing
Heartbeat to maintain connection.
Reconnect
Reconnect to a room after disconnection.
Fields
JoinAsSpectator
Join a room as a spectator (read-only observer).
LeaveSpectator
Leave spectator mode.
Trait Implementations§
Source§impl Clone for ClientMessage
impl Clone for ClientMessage
Source§fn clone(&self) -> ClientMessage
fn clone(&self) -> ClientMessage
Returns a duplicate of the value. Read more
1.0.0 · Source§fn clone_from(&mut self, source: &Self)
fn clone_from(&mut self, source: &Self)
Performs copy-assignment from
source. Read moreSource§impl Debug for ClientMessage
impl Debug for ClientMessage
Source§impl<'de> Deserialize<'de> for ClientMessage
impl<'de> Deserialize<'de> for ClientMessage
Source§fn deserialize<__D>(__deserializer: __D) -> Result<Self, __D::Error>where
__D: Deserializer<'de>,
fn deserialize<__D>(__deserializer: __D) -> Result<Self, __D::Error>where
__D: Deserializer<'de>,
Deserialize this value from the given Serde deserializer. Read more
Auto Trait Implementations§
impl Freeze for ClientMessage
impl RefUnwindSafe for ClientMessage
impl Send for ClientMessage
impl Sync for ClientMessage
impl Unpin for ClientMessage
impl UnsafeUnpin for ClientMessage
impl UnwindSafe for ClientMessage
Blanket Implementations§
Source§impl<T> BorrowMut<T> for Twhere
T: ?Sized,
impl<T> BorrowMut<T> for Twhere
T: ?Sized,
Source§fn borrow_mut(&mut self) -> &mut T
fn borrow_mut(&mut self) -> &mut T
Mutably borrows from an owned value. Read more