feat: restructure client-side code

This commit is contained in:
2025-09-04 12:33:17 +02:00
parent edaf9ea94e
commit bbce3cbadf
21 changed files with 854 additions and 20 deletions

13
src/server/game/sync.js Normal file
View File

@@ -0,0 +1,13 @@
import { broadcast } from './state.js';
export function startSyncTimer(room) {
if (room.syncTimer) clearInterval(room.syncTimer);
room.syncTimer = setInterval(() => {
if (room.state.status !== 'playing' || !room.state.currentTrack || !room.state.trackStartAt || room.state.paused) return;
broadcast(room, 'sync', { startAt: room.state.trackStartAt, serverNow: Date.now() });
}, 1000);
}
export function stopSyncTimer(room) {
if (room.syncTimer) { clearInterval(room.syncTimer); room.syncTimer = null; }
}