game_protocol API

← game_protocol · version 0.1.7

9 public items, in source order. Generated from the registry index, which re-derives them from the package source at publish time — so a signature here is the one that version actually ships.

pub enum MsgType { StateFullSync, StateDelta, PlayerInput, Ping, Pong, ChatMessage, LobbyJoin, LobbyLeave, LobbyList, MatchStart, MatchEnd, Error }

Message types for the game protocol envelope.

pub struct WsMessage { msg_type: MsgType, payload: text }

A WebSocket message wrapper for game communication.

pub struct GameEnvelope { sender: text, recipient: text, sequence: integer, timestamp: integer, message: WsMessage }

The outer envelope for all game messages. Contains routing info + the actual message.

pub fn msg_ping(seq: integer) -> GameEnvelope

Create a ping message.

pub fn msg_pong(seq: integer) -> GameEnvelope

Create a pong response.

pub fn msg_chat(sender: text, content: text) -> GameEnvelope

Create a chat message.

pub fn msg_input(sender: text, input_data: text) -> GameEnvelope

Create a player input message.

pub fn msg_state(state_data: text) -> GameEnvelope

Create a state sync message.

pub fn msg_error(error_text: text) -> GameEnvelope

Create an error message.