![]() |
Cockatrice 2026-09-01-Development-3.1.0-beta.10
A virtual tabletop for multiplayer card games
|
ServerMessage is the server-to-client message envelope used for all communication originating from the Cockatrice server.
The server never sends CommandContainer messages, and clients never send ServerMessage messages.
A ServerMessage represents either:
This document describes ServerMessage as a protocol-level concept. It should not be confused with generated protobuf accessors or wire-level encoding details.
ServerMessage instances are emitted by the server and delivered asynchronously to clients.
Delivery guarantees:
Clients must be prepared to handle ServerMessage objects at all times, regardless of pending requests.
Each ServerMessage contains exactly one payload, identified by the message_type field.
The following message types are supported:
A message containing multiple payloads or an unknown type is considered malformed.
RESPONSE messages are direct replies to client-issued CommandContainer messages.
Characteristics:
A single CommandContainer results in at most one RESPONSE.
RESPONSE messages may be preceded or followed by event messages.
Event messages are unsolicited notifications emitted by the server.
Event message types include:
Event messages:
Clients must process events independently of responses.
Session events are global to the client session and may include:
Room events are scoped to a specific room and are delivered only to clients currently present in that room.
Game events are scoped to a specific game and are delivered only to participating clients.
Game events are grouped within a GameEventContainer to allow batching.
Some ServerMessage types may contain multiple logical events.
Clients must process all contained events in order.
Errors are communicated exclusively via RESPONSE messages.
Event messages are never used to signal command failure.
Common error responses include: