pub enum ServerMessage {
Show 31 variants
Authenticated {
app_name: String,
organization: Option<String>,
rate_limits: RateLimitInfo,
},
ProtocolInfo(ProtocolInfoPayload),
AuthenticationError {
error: String,
error_code: ErrorCode,
},
RoomJoined(Box<RoomJoinedPayload>),
RoomJoinFailed {
reason: String,
error_code: Option<ErrorCode>,
},
RoomLeft,
PlayerJoined {
player: PlayerInfo,
},
PlayerLeft {
player_id: PlayerId,
epoch: Option<u32>,
final_seq: Option<u64>,
},
GameData {
from_player: PlayerId,
data: Value,
seq: Option<u64>,
epoch: Option<u32>,
class: Option<DeliveryClass>,
key: Option<u32>,
},
GameDataBinary {
from_player: PlayerId,
encoding: GameDataEncoding,
payload: Vec<u8>,
seq: Option<u64>,
epoch: Option<u32>,
},
AuthorityChanged {
authority_player: Option<PlayerId>,
you_are_authority: bool,
},
AuthorityResponse {
granted: bool,
reason: Option<String>,
error_code: Option<ErrorCode>,
},
LobbyStateChanged {
lobby_state: LobbyState,
ready_players: Vec<PlayerId>,
all_ready: bool,
},
GameStarting {
peer_connections: Vec<PeerConnectionInfo>,
},
Pong,
Reconnected(Box<ReconnectedPayload>),
ReconnectionFailed {
reason: String,
error_code: ErrorCode,
},
PlayerReconnected {
player_id: PlayerId,
epoch: Option<u32>,
},
SpectatorJoined(Box<SpectatorJoinedPayload>),
SpectatorJoinFailed {
reason: String,
error_code: Option<ErrorCode>,
},
SpectatorLeft {
room_id: Option<RoomId>,
room_code: Option<String>,
reason: Option<SpectatorStateChangeReason>,
current_spectators: Vec<SpectatorInfo>,
},
NewSpectatorJoined {
spectator: SpectatorInfo,
current_spectators: Vec<SpectatorInfo>,
reason: Option<SpectatorStateChangeReason>,
},
SpectatorDisconnected {
spectator_id: PlayerId,
reason: Option<SpectatorStateChangeReason>,
current_spectators: Vec<SpectatorInfo>,
},
Error {
message: String,
error_code: Option<ErrorCode>,
},
Signal {
from: PlayerId,
signal: Value,
},
NewPeer {
peer_id: PlayerId,
you_initiate: bool,
},
SessionPlan(Box<SessionPlanPayload>),
PeerTransportStatus {
peer_id: PlayerId,
transport: TransportKind,
connected: bool,
},
RelayStats {
interval_ms: u64,
sent_to_you: u64,
dropped_for_you: u64,
backpressure_events: u64,
},
GoingAway {
deadline_ms: u64,
retry_after_secs: Option<u64>,
},
DeliveryReport(Box<DeliveryReportPayload>),
}Expand description
Message types sent from server to client.
Variants§
Authenticated
Authentication successful.
Fields
rate_limits: RateLimitInfoRate limits for this app.
ProtocolInfo(ProtocolInfoPayload)
SDK/protocol compatibility details advertised after authentication.
AuthenticationError
Authentication failed.
RoomJoined(Box<RoomJoinedPayload>)
Successfully joined a room (boxed to reduce enum size).
RoomJoinFailed
Failed to join room.
RoomLeft
Successfully left room.
PlayerJoined
Another player joined the room.
Fields
player: PlayerInfoPlayerLeft
Another player left the room.
GameData
Game data from another player.
Fields
class: Option<DeliveryClass>GameDataBinary
Binary game data payload from another player.
Uses Vec<u8> with serde_bytes for efficient serialization.
Fields
encoding: GameDataEncodingAuthorityChanged
Authority status changed.
Fields
AuthorityResponse
Authority request response.
LobbyStateChanged
Lobby state changed (room full, player readiness changed, etc.).
GameStarting
Game is starting with peer connection information.
Fields
peer_connections: Vec<PeerConnectionInfo>Pong
Pong response to ping.
Reconnected(Box<ReconnectedPayload>)
Reconnection successful (boxed to reduce enum size).
ReconnectionFailed
Reconnection failed.
PlayerReconnected
Another player reconnected to the room.
SpectatorJoined(Box<SpectatorJoinedPayload>)
Successfully joined a room as spectator (boxed to reduce enum size).
SpectatorJoinFailed
Failed to join as spectator.
SpectatorLeft
Successfully left spectator mode.
NewSpectatorJoined
Another spectator joined the room.
Fields
spectator: SpectatorInfocurrent_spectators: Vec<SpectatorInfo>reason: Option<SpectatorStateChangeReason>SpectatorDisconnected
Another spectator left the room.
Error
Error message.
Signal
An opaque WebRTC signal relayed from a peer.
Protocol v3 only. Sent only on a v3-negotiated connection.
signal is modeled as serde_json::Value (typically a
PeerSignal) so unknown future shapes always
round-trip. Convert with PeerSignal::try_from(&signal).
Fields
NewPeer
A new peer to connect to after the session was finalized — a late joiner.
Protocol v3 only. Sent only on a v3-negotiated connection.
Fields
SessionPlan(Box<SessionPlanPayload>)
Per-recipient session plan for a finalized non-relay room.
Protocol v3 only. Boxed to reduce enum size. May be received multiple times (host re-election / late-join); each one fully replaces the previous plan.
PeerTransportStatus
A peer’s data-path transport state changed. Informational.
Protocol v3 only. Sent only on a v3-negotiated connection.
Fields
transport: TransportKindThe transport being reported on.
RelayStats
Periodic cumulative relay-delivery diagnostics (protocol v3 only).
GoingAway
Graceful server-shutdown advisory (protocol v3 only).
DeliveryReport(Box<DeliveryReportPayload>)
Exact delivery accountability (protocol v3 only).
Trait Implementations§
Source§impl Clone for ServerMessage
impl Clone for ServerMessage
Source§fn clone(&self) -> ServerMessage
fn clone(&self) -> ServerMessage
1.0.0 (const: unstable) · Source§fn clone_from(&mut self, source: &Self)
fn clone_from(&mut self, source: &Self)
source. Read more