Skip to content

[feat] selectable peer signaling server + public-cloud fallback - #27

Merged
AlexZ005 merged 1 commit into
mainfrom
feature/self-hosted-peer-turn
Jul 19, 2026
Merged

[feat] selectable peer signaling server + public-cloud fallback#27
AlexZ005 merged 1 commit into
mainfrom
feature/self-hosted-peer-turn

Conversation

@AlexZ005

Copy link
Copy Markdown
Collaborator

Adds a runtime-selectable signaling server so we can move off the rate-limited public PeerJS cloud onto our own EC2-hosted PeerServer + coturn (see docs/tf), with a safety net.

Modes (Settings -> Connection)

  • default - self-hosted server from VITE_* env; falls back to the public PeerJS cloud if the pinned server never opens. No env => just the public cloud.
  • public - public PeerJS cloud, no fallback.
  • custom - user's own server (host/port/path/TURN/STUN); no fallback.

Mode + custom fields persist to localStorage. Local dev (localhost) still uses the :9001 dev server in default mode.

Changes

  • src/lib/peerServer.js (new) - mode resolution + ICE builder, SSR-safe, VITE_* env.
  • peerHandler.svelte.js - build Peer options from the mode; connect-time fallback rebuilds against the public cloud and re-wires (custom/public never fall back).
  • voiceChat.js - split attachVoiceToPeer out of initVoiceChat so the fallback rebinds the incoming-call handler without duplicating window listeners.
  • Settings.svelte - new Connection section.
  • .env.example documents the self-hosted/TURN vars (real .env stays gitignored).

Verification

  • npm run build passes (prerender clean = peerServer.js SSR-safe).
  • npx svelte-check held at baseline 502/77.
  • network-disconnect two-peer e2e passed - and since the harness host is theprototype.app with .env present, that run exercised the fallback path (self-hosted DNS-less -> public -> connected).

🤖 Generated with Claude Code

- peerServer.js: three modes (default self-hosted / public cloud / custom),
  persisted to localStorage; self-hosted host + STUN/TURN read from VITE_* env
- peerHandler: build Peer options from the selected mode; in default mode, if
  the pinned self-hosted server never opens, rebuild against the public PeerJS
  cloud (custom/public never fall back). Rewire + rebind voice on fallback
- voiceChat: split attachVoiceToPeer out of initVoiceChat so the fallback can
  rebind the incoming-call handler without duplicating window listeners
- Settings: new Connection section (mode select + custom host/port/path/TURN)
- .env.example documents the self-hosted/TURN vars (real .env stays gitignored)

Co-Authored-By: Claude Fable 5 <noreply@anthropic.com>
@AlexZ005
AlexZ005 merged commit 7883f29 into main Jul 19, 2026
@AlexZ005
AlexZ005 deleted the feature/self-hosted-peer-turn branch August 5, 2026 20:23
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