feat: web variants use relay WS directly — no bridge needed

Updated all 3 web client variants to connect via the relay's new
WebSocket endpoint (/ws/room) instead of the wzp-web bridge.

index.html:
- Boot logic now creates the correct client class per variant
  (WZPPureClient, WZPHybridClient, or WZPFullClient)

wzp-full.js (Full WASM):
- Tries WebTransport first with 3s timeout
- Falls back to WebSocket if WT unavailable or relay lacks HTTP/3
- WS fallback sends raw PCM (same as pure), WASM FEC module still loaded
- When WT works: full encrypted + FEC pipeline over UDP datagrams

Pure + Hybrid variants already used /ws/room — no changes needed.

All JS syntax verified, 63 relay tests passing.

Co-Authored-By: Claude Opus 4.6 (1M context) <noreply@anthropic.com>
This commit is contained in:
Siavash Sameni
2026-03-30 14:43:49 +04:00
parent 137e7973c4
commit ec437afbce
2 changed files with 108 additions and 42 deletions

View File

@@ -117,8 +117,9 @@ function wzpBoot() {
var proto = location.protocol === 'https:' ? 'wss:' : 'ws:';
var wsUrl = proto + '//' + location.host + '/ws/' + encodeURIComponent(room);
// Create client (currently always WZPPureClient; future: switch on variant)
client = new WZPPureClient({
// Create client based on selected variant
var variant = WZPCore.detectVariant();
var clientOpts = {
wsUrl: wsUrl,
room: room,
onAudio: function(pcm) {
@@ -130,7 +131,17 @@ function wzpBoot() {
onStats: function(stats) {
WZPCore.updateStats(stats);
},
});
};
if (variant === 'full' && typeof WZPFullClient !== 'undefined') {
// Full variant: add WebTransport URL, falls back to WS if WT unavailable
clientOpts.url = location.origin.replace('http', 'https');
client = new WZPFullClient(clientOpts);
} else if (variant === 'hybrid' && typeof WZPHybridClient !== 'undefined') {
client = new WZPHybridClient(clientOpts);
} else {
client = new WZPPureClient(clientOpts);
}
try {
await client.connect();