Skip to content

Get TURN from the server instead of URL params - #12

Merged
vetonshabani0 merged 1 commit into
mainfrom
feat/server-vended-ice
Jul 23, 2026
Merged

Get TURN from the server instead of URL params#12
vetonshabani0 merged 1 commit into
mainfrom
feat/server-vended-ice

Conversation

@vetonshabani0

Copy link
Copy Markdown
Collaborator

TURN credentials used to reach the phone as query params, put there by an untracked dev helper the launcher's QR pointed at. The QR now goes straight to this app (space-console/game-launcher-web#15) and carries no credentials — and it couldn't, since this repo is public. So rtcConfig() takes its ICE servers from the server's /api/ice (space-console/web-api#6).

The fetch runs once at load into a module-level cache. connect() awaits it before building the RTCPeerConnection, whose ICE servers are fixed at construction; by the time anyone taps Join it has long since settled. Callers don't use the return value, so connect() stays synchronous for them.

A Leave or a second Join while the fetch is still in flight bumps a generation counter in _closeConnections(), so a superseded attempt can't open a peer behind it.

Query params still override for a one-off device, and a missing /api/ice falls back to STUN, which still covers same-network play.

Verified

  • npm run lint clean.
  • Served from the workspace root: /api/ice fetch present in the served bundle.
  • Full signaling handshake (create → join → SDP relayed both ways) still passes.

Merge before space-console/web-api#6 — its build pulls this repo's gh-pages, which only republishes after this lands on main.

TURN credentials used to reach the phone as query params, put there by an
untracked dev helper the launcher's QR pointed at. The QR now goes straight to
this app and carries no credentials — and it couldn't, since this repo is
public — so rtcConfig() takes its ICE servers from the server's /api/ice.

The fetch runs once at load into a module-level cache. connect() awaits it
before building the RTCPeerConnection, whose ICE servers are fixed at
construction; by the time anyone taps Join it has long since settled. Callers
don't use the return value, so connect() stays synchronous for them. A Leave or
a second Join while the fetch is still in flight bumps a generation counter in
_closeConnections(), so a superseded attempt can't open a peer behind it.

Query params still override for a one-off device, and a missing /api/ice falls
back to STUN, which still covers same-network play.
@github-actions

Copy link
Copy Markdown
Contributor

🚀 Preview for feat/server-vended-ice: https://space-console.github.io/game-controller/preview/feat-server-vended-ice-4c47/

@vetonshabani0
vetonshabani0 merged commit 239699a into main Jul 23, 2026
4 checks passed
@vetonshabani0
vetonshabani0 deleted the feat/server-vended-ice branch July 23, 2026 16:31
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Labels

None yet

Projects

None yet

Development

Successfully merging this pull request may close these issues.

1 participant