플레이어가 모두 사이트를 닫으면 게임 중·끝난 방을 1분 뒤 닫기(관전자는 셈하지 않음)

- 게이트웨이가 사용자별 '마지막 소켓이 닫힌 시각'을 기록(offlineSince). 소켓이 하나라도 열려 있으면 사이트에 있는 것
- sweep: 대기실이 아닌 방에서 자리에 앉은 사람(컴퓨터·게임 중 나간 사람 제외)이 모두 사이트를 떠난 지 1분이면
  게임을 무효로 끝내고 방을 닫는다. 관전자가 접속해 있어도 닫고 내보낸다. 대기실은 초대 입장 때문에 기존 규칙 유지
- 홈 등 다른 화면에서 새로 연 창도 자리가 있으면(/api/me activeRoom) 소켓을 연결해 '사이트 열림'으로 남게
- Room.closeByAdmin을 closeWith(summary, notice)로 일반화
- e2e(bots): 오목은 컴퓨터가 3번만 받게(이후 단계 전에 게임이 끝나지 않게), 홈 단계를 원카드 앞으로(턴 시간 초과 방지)

Co-Authored-By: Claude Opus 5.5 <noreply@anthropic.com>
This commit is contained in:
EJClaw
2026-10-08 09:47:22 +09:00
parent 0a587a8b98
commit f5671cda70
10 changed files with 229 additions and 34 deletions

View File

@@ -2,6 +2,7 @@
import { create } from 'zustand';
import type { CatalogEntry, PublicUser } from '@bg/shared/lite';
import { api, type Settings } from '../net/api';
import { socket } from '../net/socket';
const LS_KEY = 'bg.settings';
@@ -94,6 +95,9 @@ export const useSession = create<SessionState>((set, get) => ({
useAvatar: me.useAvatar ?? true,
hasDiscordAvatar: me.hasDiscordAvatar ?? false,
});
// Holding a seat: stay connected on every page so the server knows the site is still open (a game whose
// players all closed the site gets closed, docs/06 §11).
if (me.activeRoom) socket.start();
},
setMe(me) {
set({ me });