Add co-op server, deploy docs, e2e suite and wire in the music tracks
- server/: Node (ws) static server + authoritative co-op rooms; dual-stack listen, proxy-aware client IP and Origin check, keep-alive pings, per-socket rate limits, graceful shutdown; 59 node:test tests - docs/DEPLOY.md + deploy/netwall.service: Debian 13 LXC, systemd, nginx Proxy Manager walk-through, path prefix, troubleshooting - e2e/: Playwright suite (smoke, touch, end flow, two-browser co-op incl. reconnect, 14-size layout matrix); npm run e2e - Music: tracks.json now points at the uploaded theme/battle/boss/win/lose files; stingers fade out when a new game starts - PAUSED indicator, refreshed icon Co-Authored-By: Claude Sonnet 5.5 <noreply@anthropic.com> Claude-Session: https://claude.ai/code/session_01Tb8pW2KAN4oFkh1aK1BfD8
This commit is contained in:
parent
1c2071e6db
commit
faf0cfa603
27 changed files with 3383 additions and 28 deletions
|
|
@ -37,8 +37,9 @@ at a domain root and under a path prefix the proxy strips.
|
|||
the server sends a WebSocket *protocol* ping to each socket and terminates sockets that did not pong since the
|
||||
previous round (so a dead mobile client is noticed within ~2 rounds and goes into the grace period).
|
||||
* **Real client IP** is used only for logging and the per-IP socket cap `maxConnPerIp`. `trustProxy:'auto'`
|
||||
means: if the TCP peer is loopback / RFC1918 / `fc00::/7` / link-local, take the first address of
|
||||
`X-Forwarded-For` (else `X-Real-IP`) as the client IP; otherwise use the TCP peer and ignore those headers.
|
||||
means: if the TCP peer is loopback / RFC1918 / `fc00::/7` / link-local, take the client IP from
|
||||
`X-Forwarded-For` (else `X-Real-IP`): the *rightmost* entry that is not a private address (proxies append, so
|
||||
entries further left are the client's own forgeable claim); otherwise use the TCP peer and ignore those headers.
|
||||
`true`/`false` force it. `maxConnPerIp: 0` disables the cap. Reject extra sockets with HTTP `429` on upgrade.
|
||||
* **Origin check** (see below) accepts: Origin host == `Host` header; or == `X-Forwarded-Host` when the proxy is
|
||||
trusted; or the Origin is listed in `allowedOrigins`. Compare scheme-less `host[:port]`, treat default ports
|
||||
|
|
@ -91,6 +92,10 @@ Success: reply to the joiner
|
|||
```
|
||||
then broadcast `{ t:'players', players:[...] }` to all *other* players.
|
||||
|
||||
`pid` is the reconnect secret (whoever presents it takes the slot), so in every `players` list it is the viewer's own
|
||||
pid for the viewer's own entry and an opaque, stable per-room alias for the other player's entry. Compare entries by
|
||||
`pid` within the lists you receive and find yourself with `you.pid`; never expect to see the other player's real pid.
|
||||
|
||||
* A player owns a **slot** (0 or 1), the lowest free one, kept until they leave for good.
|
||||
* **Host** = creator; if the host leaves for good the other player becomes host.
|
||||
* **Reconnect**: a `join` whose `pid` already holds a slot in that room re-binds to it (`resumed:true`); the old
|
||||
|
|
|
|||
Loading…
Add table
Add a link
Reference in a new issue