0014. Multiplayer transport: WebSocket first, WebRTC/WebTransport behind an interface (provisional)
- Status: Accepted (confirmed 2026-11-30 with a change: a deterministic input relay instead of server-authoritative
rooms, see ADR 0027; WebSocket first behind
NetTransportstands) - Date: 2026-11-26
- Phase: 6
Context
Section titled “Context”The brief asks to choose WebSocket, WebRTC or both, and justify it.
Decision
Section titled “Decision”Start with server-authoritative rooms over WebSocket, behind a NetTransport interface:
- WebSocket works in every browser, through corporate proxies and with standard load balancers; it is easy to authenticate, rate-limit, log and moderate; and it suits the turn-based, co-op, party and casual real-time games most creators will make.
- Server authority prevents cheating and lets the server validate inputs — important for untrusted user games.
- Evaluate Colyseus (MIT, room/matchmaking/state-sync) as the room server at Phase 6 instead of writing our own.
- Add a second transport for fast-action games: WebTransport (unreliable datagrams over HTTP/3) where supported, or WebRTC DataChannels client↔server (not peer-to-peer). Peer-to-peer WebRTC is avoided: it exposes player IPs, needs TURN servers anyway, and cannot be made authoritative.
Alternatives considered
Section titled “Alternatives considered”- WebRTC only: unreliable/unordered channels help fast shooters, but signalling + TURN + NAT issues, and harder ops.
- Both from day one: double the surface before we know the need.
Consequences
Section titled “Consequences”WebSocket’s head-of-line blocking limits twitch games; the interface allows adding datagrams later. Game servers are long-lived processes — another reason for containers (ADR 0011).