Watch party refresh: Chat/Queue/Room tabs, host transport, gentle sync, heartbeat and latency-aware reconnect, in-place section updates

This commit is contained in:
Jonathan Sykes
2026-10-15 20:19:44 +08:00
parent 23097918e9
commit 088937d4de
12 changed files with 550 additions and 84 deletions

View File

@@ -134,7 +134,9 @@ export function createPartyHub({ now = () => Date.now() } = {}) {
if (me.tokens < 1) return; // flood: drop
me.tokens -= 1;
}
if (m.type === 'direct') {
if (m.type === 'ping') {
send(ws, { type: 'pong', echo: Number(m.echo) || 0, now: now() });
} else if (m.type === 'direct') {
p.direct.handle(me.pid, m, new Map([...p.members].map(([pid, member]) => [pid, member.ws])), send);
} else if (m.type === 'dj') {
if (m.action === 'take' && isHost) { const video = takeDJVideo(p.dj); send(ws, { type: 'dj-play', video }); if (video) broadcast(p, { type: 'dj', ...queueSnapshot(p.dj) }); }