Skip to main content

Module protocol

Module protocol 

Source
Expand description

Protocol module for RuneCast WebSocket communication.

This module defines all message types exchanged between the frontend client and backend server over WebSocket connections.

§Architecture

┌─────────────────────────────────────────────────────────────────────┐
│                           Protocol Layer                             │
├─────────────────────────────────────────────────────────────────────┤
│  types.rs        - Shared data types (Grid, Position, etc.)         │
│  client_messages - Client → Server message definitions              │
│  server_messages - Server → Client message definitions              │
└─────────────────────────────────────────────────────────────────────┘

§Message Flow

Client                                Server
  │                                      │
  │◀─── Hello ──────────────────────────│
  │                                      │
  │──── JoinChannelLobby ──────────────▶│
  │◀─── LobbyJoined ────────────────────│
  │                                      │
  │──── StartGame ─────────────────────▶│
  │◀─── GameStarted ────────────────────│
  │                                      │
  │──── SubmitWord ────────────────────▶│
  │◀─── WordScored ─────────────────────│
  │◀─── TurnChanged ────────────────────│

Re-exports§

pub use client_messages::ClientMessage;
pub use server_messages::LobbySnapshot;
pub use server_messages::ServerMessage;
pub use types::*;

Modules§

client_messages
Client-to-server messages.
server_messages
Server-to-client messages.
types
Shared types used in protocol messages.

Constants§

HEARTBEAT_INTERVAL_MS
Recommended heartbeat interval (client should send heartbeat this often).
HEARTBEAT_TIMEOUT_MS
Heartbeat timeout (server closes connection if no heartbeat received).
MAX_MESSAGE_SIZE
Maximum message size in bytes.
PROTOCOL_VERSION
Protocol version for compatibility checks.
RECONNECT_GRACE_MS
Grace period for reconnection before session expires.