feat(partyplug): adopt HexStacker's room-teardown kit + wire close-room#5
Merged
Conversation
Sync PartyConnection with the HexStacker-Party reference:
- closeRoom(): host/slot-0 tears the room down on the relay (members get
a 4001 close, GET /room/:code turns 404 so stale join/claim QRs die)
- 4001 handling: terminal onClose {roomClosed} — no futile reconnects
against a deleted room
- create(maxClients, url): register a controller-URL template ({room}/
{instance}) the relay resolves for code-only clients (https-only)
- failAttempt(): drive the normal backoff path for self-detected failures
(open socket, unanswered create)
Game wiring:
- display pagehide: closeRoom() after the DISPLAY_CLOSED goodbye, so the
room dies server-side even when the app-level broadcast is dropped
- display create: pass the controller-URL template; a rejected create now
retries via failAttempt() instead of dead-ending on a warn
- controller: {roomClosed} surfaces as 'room_closed' and bails straight
to the device chooser (?bail=game_ended), same exit as DISPLAY_CLOSED
set_state (retained roster snapshot) was already in place. Verified the
deployed relay honors the new contract (4001 both sockets, /room 404).
Co-Authored-By: Claude Fable 5 <noreply@anthropic.com>
Claude-Session: https://claude.ai/code/session_01WrjJk5evnn2g63cD2eaqhC
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment
Add this suggestion to a batch that can be applied as a single commit.This suggestion is invalid because no changes were made to the code.Suggestions cannot be applied while the pull request is closed.Suggestions cannot be applied while viewing a subset of changes.Only one suggestion per line can be applied in a batch.Add this suggestion to a batch that can be applied as a single commit.Applying suggestions on deleted lines is not supported.You must change the existing code in this line in order to create a valid suggestion.Outdated suggestions cannot be applied.This suggestion has been applied or marked resolved.Suggestions cannot be applied from pending reviews.Suggestions cannot be applied on multi-line comments.Suggestions cannot be applied while the pull request is queued to merge.Suggestion cannot be applied right now. Please check back later.
Summary
Syncs the PartyPlug kit with the HexStacker-Party reference and wires the new close-room lifecycle into the game.
set_state(retained roster snapshot) was already adopted here, so this PR covers the remaining delta: room teardown, terminal-close handling, the controller-URL template, and self-detected create failures.Kit sync (
partyplug/PartyConnection.js+.d.ts, README, tests)closeRoom()— host/slot-0 tears the room down on the relay: every member socket closes with 4001 andGET /room/:codeturns 404, so stale join/claim QRs die with the roomonClose(0, 0, {roomClosed: true}); no auto-reconnect against a deleted roomcreate(maxClients, url)— optional controller-URL template ({room}/{instance}) the relay resolves for code-only clients; https-only, omitted on plain-http origins (dev/E2E)failAttempt()— drives the normal backoff/give-up path for failures the caller detects itself (open socket, unanswered/rejected create)Only
PartyConnectiondiffered from the reference — RoomFlow, PartyFastlane, and the AirConsole adapter were already identical.Game wiring
net.closeRoom()right after the existingDISPLAY_CLOSEDbroadcast — the room now dies server-side even when the app-level goodbye is dropped (crash, bfcache freeze); the broadcast stays as the instant pathfailAttempt()backoff instead of dead-ending on a console warning{roomClosed}surfaces as'room_closed'and bails straight to the device chooser (?bail=game_ended), same exit asDISPLAY_CLOSEDTesting
npm test: 212/212 pass (includes the new closeRoom / 4001 / create-url kit tests)npm run test:e2e: 17/17 pass over the real relay — "closing the big screen bails joined phones out at once" now exercises the new pathws.couch-games.com) directly: accepts theurltemplate, closes host + guest sockets with 4001 onclose_room, and 404s the room afterward🤖 Generated with Claude Code
https://claude.ai/code/session_01WrjJk5evnn2g63cD2eaqhC