Networking

Networking

Authoritative multiplayer server with WebRTC and tick-based state sync.

MavonEngine uses an authoritative server architecture for multiplayer. The server is the single source of truth — clients send commands, the server processes them, and broadcasts state back to clients.

Reference: The architecture is inspired by Gaffer On Games and Source Engine Multiplayer Networking.

Transport

Real-time data is sent over UDP via WebRTC using geckos.io. This gives low-latency unreliable messaging suitable for game state synchronization.

Architecture overview

Client                          Server
  │                               │
  │── command (input) ──────────► │
  │                               │  1) process command
  │                               │  2) step physics
  │                               │  3) update state
  │◄── state sync (tick) ──────── │
  │                               │
  1. Client captures input and sends commands to the server
  2. Server queues commands in a command buffer
  3. On each tick, the server processes commands, steps physics, and broadcasts world state
  4. State is only sent to clients within the visibility radius of each entity

Key classes

Server

Authoritative server with command buffer, tick loop, and HTTP health endpoint.

NetworkManager

Client-side WebRTC connection with ping monitoring.

Networked Actors

NetworkedActor, NetworkedGameObject, and state synchronization utilities.

State Sync

How entity state is serialized and synchronized between server and clients.