Race state websocket #4

Closed
opened 2026-10-17 02:09:13 +00:00 by mintopia · 2 comments
Owner

What to build

External apps can connect to a local websocket server the game opens when BLUR_STATE_WS=<port> is set (off by default, localhost only). On connect a client gets a JSON snapshot of the game-state feed, then a JSON message for every change. The message format is documented.

Acceptance criteria

  • With BLUR_STATE_WS set, a websocket client (e.g. websocat) gets a snapshot on connect, then changes as the player moves through menus/events/lobbies
  • Multiple clients at once; client disconnects don't affect the game
  • Unset: no listener is opened
  • Binds to localhost only
  • Message format documented; env var in the README table
  • Verified on BLUR_ENGINE=recomp

Blocked by

## What to build External apps can connect to a local websocket server the game opens when `BLUR_STATE_WS=<port>` is set (off by default, localhost only). On connect a client gets a JSON snapshot of the game-state feed, then a JSON message for every change. The message format is documented. ## Acceptance criteria - [ ] With `BLUR_STATE_WS` set, a websocket client (e.g. `websocat`) gets a snapshot on connect, then changes as the player moves through menus/events/lobbies - [ ] Multiple clients at once; client disconnects don't affect the game - [ ] Unset: no listener is opened - [ ] Binds to localhost only - [ ] Message format documented; env var in the README table - [ ] Verified on `BLUR_ENGINE=recomp` ## Blocked by - #2
Author
Owner

Implemented. BLUR_STATE_WS=<port> starts a Network.framework websocket server bound to 127.0.0.1 only (src/host/state_ws.mm); unset = no listener. On connect: {"type":"snapshot","state":{...}}, then {"type":"change","key":..,"value":..} per change (format in docs/state-websocket.md, env var in README). Multiple clients supported; disconnects dont affect the game. Verified on BLUR_ENGINE=recomp via mdrive.py mp_menus: snapshot + live screen/mode changes received, lsof shows only 127.0.0.1:port listening, second client connect/kill left game and first client running. Unit test state_ws_test added (ctest state_ws passes). Lobby/event-track keys come from the existing #2 feed and were not exercised by this menu plan.

Implemented. `BLUR_STATE_WS=<port>` starts a Network.framework websocket server bound to 127.0.0.1 only (`src/host/state_ws.mm`); unset = no listener. On connect: `{"type":"snapshot","state":{...}}`, then `{"type":"change","key":..,"value":..}` per change (format in `docs/state-websocket.md`, env var in README). Multiple clients supported; disconnects dont affect the game. Verified on `BLUR_ENGINE=recomp` via `mdrive.py mp_menus`: snapshot + live screen/mode changes received, `lsof` shows only `127.0.0.1:port` listening, second client connect/kill left game and first client running. Unit test `state_ws_test` added (ctest state_ws passes). Lobby/event-track keys come from the existing #2 feed and were not exercised by this menu plan.
Author
Owner

Completed and merged by Harmonic (task 7).

Completed and merged by Harmonic (task 7).
Sign in to join this conversation.
No project
No assignees
1 participant
Notifications
Due date
The due date is invalid or out of range. Please use the format "yyyy-mm-dd".

No due date set.

Blocks Depends on
#2 Game-state feed
mintopia/blur
Reference
mintopia/blur#4
No description provided.