You signed in with another tab or window. Reload to refresh your session.You signed out in another tab or window. Reload to refresh your session.You switched accounts on another tab or window. Reload to refresh your session.Dismiss alert
Replace game-specific protocol (join/state/chat/snapshot) with a
universal relay model. Server manages rooms and connections but treats
game data as opaque payloads — any msgpack client works.
- Auto-join on WebSocket connect (no handshake required)
- Relay messages immediately to peers (no server-side tick loop)
- Remove SNAPSHOT_HZ env var
- New message types: welcome, peer_joined, peer_left, relay, ping/pong
Copy file name to clipboardExpand all lines: README.md
+63-29Lines changed: 63 additions & 29 deletions
Display the source diff
Display the rich diff
Original file line number
Diff line number
Diff line change
@@ -1,6 +1,6 @@
1
1
# bun-ws-gameserver
2
2
3
-
Production-grade Bun-native WebSocket game server with room-based architecture, binary protocol (msgpack), server-authoritative tick loop, and per-client rate limiting. 5-8x faster than Node.js `ws` — same protocol, same clients.
3
+
Protocol-agnostic Bun-native WebSocket relay server with room-based architecture, binary protocol (msgpack), and per-client rate limiting. 5-8x faster than Node.js `ws` — same protocol, same clients.
4
4
5
5
[](https://app.alternatefutures.ai/deploy/bun-ws-gameserver)
6
6
@@ -10,9 +10,9 @@ Production-grade Bun-native WebSocket game server with room-based architecture,
Both [`node-ws-gameserver`](https://github.com/alternatefutures/node-ws-gameserver) and `bun-ws-gameserver` use the same **msgpack binary protocol**, so clients are backend-agnostic.
60
+
Both [`node-ws-gameserver`](https://github.com/mavisakalyan/node-ws-gameserver) and `bun-ws-gameserver` use the same **msgpack binary relay protocol**, so clients are backend-agnostic.
62
61
63
-
### Client → Server
62
+
The server is **protocol-agnostic** — it manages rooms and connections, but treats game data as opaque payloads. Any client that speaks msgpack can use it: multiplayer games, collaborative tools, IoT dashboards, chat apps, etc.
63
+
64
+
### Connection Flow
65
+
66
+
1. Client connects to `ws://host/ws/:roomId`
67
+
2. Server auto-assigns a `playerId` and sends `welcome` with list of existing peers
68
+
3. Client sends any msgpack messages — server wraps each in a `relay` envelope and forwards to all other peers
69
+
4. When peers join/leave, server notifies all remaining peers
0 commit comments