Networking Architecture
Hyperscape uses a server-authoritative architecture with WebSocket-based real-time communication. The server runs at 600ms ticks while clients render at 60 FPS using prediction and interpolation.Network code lives in
packages/shared/src/systems/client/ClientNetwork.ts (2640+ lines) and packages/server/src/systems/ServerNetwork/.Architecture Overview
Connection URLs
CORS Configuration
The server automatically allows connections from:- Production:
https://hyperscape.club,https://www.hyperscape.club - Staging:
https://staging.hyperscape.club - Preview:
https://*.hyperscape.pages.dev - Development:
http://localhost:*(any port)
Binary Protocol
Communication uses msgpackr binary serialization for efficiency.Packet Format
Entity Update Optimization
Entity updates use abbreviated keys to minimize bandwidth:Example Packet
Packet Types
Client → Server
Server → Client
Client-Side Prediction
The client predicts movement locally for responsive controls, then reconciles with server authority.Prediction Flow
Interpolation for Remote Entities
Server Network System
The server handles all authoritative game logic.Connection Flow
Packet Handlers
Event Bridge
TheEventBridge converts game events to network packets automatically.
Network Constants
Rate Limiting
Network handlers use sliding window rate limiters to prevent abuse:- Per-player tracking
- Sliding window algorithm (more accurate than fixed window)
- Automatic stale entry cleanup
- Configurable cleanup interval (60s default)