Files
gomoku/server/database
tiennm99 34b0f8f2ce feat(state): watching state with room snapshot replay and spectator-cannot-act
- Add StateWatching to consts/const.go (iota value 8)
- Register watchingState in state.go runner init()
- Add sendRoomSnapshot helper in game_shared.go: sends WatchGameSuccessResponse,
  GameStartingResponse, and one GameMoveSuccessResponse per MoveHistory entry
  using room.Snapshot() to avoid holding lock during Send calls
- Update home.go: handle WatchGameRequest → WatchNewRoom + sendRoomSnapshot →
  StateWatching; RoomPlayFailNotFoundResponse on missing room
- New watching.go: WatchGameExitRequest → UnwatchNewRoom + ShowOptions → StateHome;
  ClientExitRequest → UnwatchNewRoom → ErrClientExit; GameMoveRequest →
  SpectatorCannotActResponse + stay; closed CmdCh → UnwatchNewRoom → ErrClientExit
- Update store.go LeaveNewRoom: when last player leaves, collect and eject spectators
  (clear Spectators map under lock, then send ClientExitResponse + push synthetic
  WatchGameExitRequest to each spectator CmdCh after releasing lock)
2026-04-11 15:08:15 +07:00
..