mirror of
https://github.com/tiennm99/gomoku.git
synced 2026-05-24 00:24:30 +00:00
34b0f8f2ce
- 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)