퀴즈 중 새로고침해도 이어서: 같은 계정이 돌아오면 노래가 나오는 중엔 catchup(서버 시작 시각·위치)으로 소리 끈 채 맞춰 두고 '참가 (소리 켜기)' 누르는 순간 같은 위치에서 재생(다른 사람은 안 멈춤), 준비 중엔 prepare를 다시 보내 그 사람을 기다림(예전엔 문제가 멈출 수 있었음). 지금 문제 정답도 인정. 방장은 끊겨도 15초 유지 후 넘김. 늦게 시작한 play는 지금 위치부터

Co-Authored-By: Claude Opus 5.5 <noreply@anthropic.com>
This commit is contained in:
EJClaw
2026-10-19 22:40:12 +09:00
parent 6ed669d5b4
commit 8e6fd229da
10 changed files with 247 additions and 12 deletions

View File

@@ -504,6 +504,24 @@ export class Game {
this.broadcast();
}
/**
* A player of this question is back (refresh / reconnect, same account within the grace period): bring their player to
* where everyone is. Waiting for ready → prepare again (their new page has nothing loaded, so the room waits for them);
* music running → catch up on the running timeline without stopping anyone. They can answer as before.
*/
rejoin(userId: string, send: (m: ServerMessage) => void): void {
if (!this.listening || !this.song?.videoId || !this.participants.has(userId) || this.excluded.has(userId)) return;
if (this.phase !== 'prepare' && this.phase !== 'play') return;
if (this.awaitingReady) {
this.ready.delete(userId);
if (!this.waitingSince.has(userId)) this.waitingSince.set(userId, this.now());
send({ t: 'prepare', code: this.room.code, n: this.n, videoId: this.song.videoId, startSec: this.resumeAt, endSec: this.clip.endSec });
this.broadcast();
} else if (this.playing && !this.clipOver) {
send({ t: 'catchup', code: this.room.code, n: this.n, videoId: this.song.videoId, clipStart: this.clip.startSec, startAt: this.audioStartAt, atSec: this.audioAtSec, endSec: this.clip.endSec });
}
}
/** Host: leave out someone who has not been ready for 30s (docs/12 Q1). */
exclude(target: string): string | null {
const since = this.waitingSince.get(target);