Expand description
RuneCast Protocol Library
This crate defines the WebSocket protocol for RuneCast, including:
- Message envelopes with sequence numbers for reliable delivery
- Client-to-server message types
- Server-to-client message types
- Shared data types (
Grid,Position,PlayerInfo, etc.) - Player identity and context types
- Compatibility layer for gradual migration
§Usage
use runecast_protocol::protocol::{ClientMessage, ServerMessage, Envelope};
// Parse an incoming client message
let json = r#"{"type":"heartbeat"}"#;
let msg: ClientMessage = serde_json::from_str(json).unwrap();
// Create a server response
let response = ServerMessage::HeartbeatAck {
server_time: 1701234567890,
};
// Optionally wrap in envelope for reliable delivery
let envelope = Envelope::new(42, response);Re-exports§
pub use player::PlayerContext;pub use player::PlayerIdentity;pub use protocol::compat::legacy_game_state_to_snapshot;pub use protocol::compat::parse_client_message;pub use protocol::compat::serialize_server_message;pub use protocol::compat::snapshot_to_legacy_game_state;pub use protocol::client_messages::ClientMessage;pub use protocol::envelope::Envelope;pub use protocol::envelope::MaybeEnveloped;pub use protocol::server_messages::ServerMessage;pub use protocol::types::AdminGameInfo;pub use protocol::types::DebugBackendGameState;pub use protocol::types::DebugHandlerGameState;pub use protocol::types::DebugLobbyState;pub use protocol::types::DebugPlayerInfo;pub use protocol::types::DebugWebsocketContext;pub use protocol::types::ErrorCode;pub use protocol::types::GameChange;pub use protocol::types::GameConfig;pub use protocol::types::GamePlayerInfo;pub use protocol::types::GameSnapshot;pub use protocol::types::GameState;pub use protocol::types::GameSummary;pub use protocol::types::Grid;pub use protocol::types::GridCell;pub use protocol::types::LobbyChange;pub use protocol::types::LobbyGameInfo;pub use protocol::types::LobbyGamePlayerInfo;pub use protocol::types::LobbyPlayerInfo;pub use protocol::types::LobbyType;pub use protocol::types::Multiplier;pub use protocol::types::PlayerInfo;pub use protocol::types::Position;pub use protocol::types::ScoreInfo;pub use protocol::types::SpectatorInfo;pub use protocol::types::TimerVoteState;pub use protocol::LobbySnapshot;