wyrt_sync
v1.0.0Multiplayer
Rooms of players who see each other: game-agnostic state sync for browser games, and the server half of Glyft's network rule
Requires:wyrt_core
Features
- Guests join a room by name, no account or database needed
- Each client owns its player and sends its state; the server checks every value
- Everyone else's state goes out 15 times a second, only when it changed
- One-off events (an attack, a wave, a trade) relayed straight away
- Shared things (a horse, a boat) remembered where they were left, for late joiners
- Room and player limits, rate-limited handlers, a /sync/health check
Quick Start
// With Glyft, multiplayer is one rule in the game's config:
network: { server: 'wss://your-server.example/sync', room: 'island', name: 'Ada' }
// Any other client speaks the protocol directly over a WebSocket:
ws.send(JSON.stringify({ type: 'syncJoin', room: 'island', name: 'Ada' }));
// your state, about 15 times a second:
ws.send(JSON.stringify({ type: 'syncState', s: { a: 'island', x, y, z, f, vx, vy } }));
ws.send(JSON.stringify({ type: 'syncEvent', n: 'wave', d: { at: 'tower' } }));
// The server sends:
// sync:welcome { id, name, players: [{ id, name, s }], objects }
// sync:joined { id, name } sync:left { id }
// sync:snap { players: [{ id, s }] } sync:event { id, n, d }