Skip to content

feat(netplay): resume UDP sessions and extend per-peer grace - #2728

Open
houko wants to merge 1 commit into
mainfrom
feat/issue-1692-resume-token-udp-grace
Open

houko wants to merge 1 commit into
mainfrom
feat/issue-1692-resume-token-udp-grace

Conversation

@houko

@houko houko commented Dec 1, 2026

Copy link
Copy Markdown
Contributor

Summary

A browser tab that reloads or a phone app the OS kills mid-game could not resume its netplay session: the resume state lived only inside the transport object, so it joined as a new peer while its old session held a seat for the grace period, and the grace period was one value for the whole transport (#1692). This completes the stored resume token work already present for native and WebAssembly WebSocket clients: UDPClient.ResumeToken and DialUDPResume present the same versioned base64url credential through the existing encrypted UDP hello, falling back to a fresh join when the session has ended or the server rotated the secret, with the wire format unchanged. WebSocketServer.ExtendGrace and UDPServer.ExtendGrace let a room give one dropped peer a longer window than Auth.GracePeriod, capped by the new Auth.MaxGracePeriod, whether the peer is still connected (the window applies at its drop) or already inside its grace period. Tests cover both transports, including a GOOS=js WebSocket resume test against a fake browser socket, and the en/zh docs, changelog fragment and note are updated.

Related issue

Fixes #1692

Verification

  • gofmt -l . produces no output
  • go tool nsgo test ./... passes from the repository root — ran the affected package only, go tool nsgo test ./pkg/online/netplay/... (313 pass), plus GOOS=js GOARCH=wasm go test -exec ... ./pkg/online/netplay -run TestJS (both WebAssembly tests pass under node); the full repository suite is left to CI
  • go tool nsgo check -target macos,windows,linux,android,web passes from the repository root — go tool nsgo check (host) passes and GOOS=js GOARCH=wasm go vet ./pkg/online/netplay passes; the full multi-target run could not finish because the local disk is full (2 GB free), left to CI
  • go tool nsgo check -target ios,ios_simulator passes (if on macOS with Xcode) — not run; this change touches no platform-specific code
  • bun run build passes (for docs/ or website/ changes) — not run for the same disk constraint; the change only mirrors markdown sections in docs/en and docs/zh, left to CI
  • Both docs/en/ and docs/zh/ updated (when applicable)

Screenshots

No visible UI change.

@github-actions github-actions Bot added size/M enhancement New feature or request documentation Improvements or additions to documentation area/agents pkg/online and removed enhancement New feature or request labels Dec 1, 2026
Add UDPClient.ResumeToken and DialUDPResume so a restarted app presents a stored credential instead of joining as a new peer, completing the stored resume token support that already existed for WebSocket clients on native and WebAssembly builds. The token carries the peer ID and resume secret through the existing hello fields, so the wire format is unchanged.

Add WebSocketServer.ExtendGrace and UDPServer.ExtendGrace, capped by the new Auth.MaxGracePeriod, so a room can keep one dropped peer's seat longer than Auth.GracePeriod, whether the peer is still connected (the window applies at its drop) or already inside its grace period.

Cover both transports with resume-token and grace tests, add a GOOS=js test of the WebSocket resume path against a fake browser socket, and update the en/zh netplay docs, changelog fragment and note.

Fixes #1692
@houko
houko force-pushed the feat/issue-1692-resume-token-udp-grace branch from d91b95f to 9147103 Compare December 1, 2026 03:32
@github-actions github-actions Bot added the enhancement New feature or request label Dec 1, 2026

This branch has not been deployed

No deployments
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Labels

area/agents documentation Improvements or additions to documentation enhancement New feature or request pkg/online size/M

Projects

None yet

Development

Successfully merging this pull request may close these issues.

Net: a resume token clients can store, so a reloaded web page or restarted app rejoins its session within the grace period

1 participant