Files
tiennm99 81234b5ab9 fix(wsapi): stop a kicked token resuming into another seat, harden limits
A held seat now remembers which connection it waits for, so a token
from a kicked player is refused instead of landing in whoever took the
seat. A room answers every input left in its inbox when it exits,
disconnect notices no longer share the lossy inbox, quick-match no
longer leaves autoStart armed after a pairing that never started, only
lobby changes restart the idle window, and draining refuses new queue
entries.

Sockets that never send Hello close after ten seconds and the room
budget is charged per address, so one client cannot hold the global
caps. IPv6 limiter keys use the /64. Corpus log lines get a process-wide
rate limit with a suppressed counter. Responses carry nosniff,
frame-ancestors and referrer headers. Unicode spaces in a word become
spaces rather than vanishing, and blank-rendering letters are dropped
from names and chat. A resume into a lobby whose game ended during the
absence is replayed that seat's GameOver. Unknown payloads get
unknown_message.
2026-09-29 20:33:16 +07:00

53 lines
2.7 KiB
Go

package wsapi
// errCode is a ServerError.code: a key the client turns into a message, not
// text shown as is. Every code the transport can send is declared here and
// nowhere else, so the vocabulary the web client has to translate is one list
// — web/tests/error-codes.test.js reads it from this file.
type errCode string
const (
codeAlreadyGreeted errCode = "already_greeted"
codeAlreadyInAGame errCode = "already_in_a_game"
codeAlreadyInARoom errCode = "already_in_a_room"
codeAlreadyQueued errCode = "already_queued"
codeBadFrame errCode = "bad_frame"
codeBusy errCode = "busy"
codeCannotJoinOwnRoom errCode = "cannot_join_own_room"
codeCannotKickSelf errCode = "cannot_kick_self"
codeGameAlreadyOver errCode = "game_already_over"
codeGameInProgress errCode = "game_in_progress"
codeGameNotStarted errCode = "game_not_started"
codeGameStartFailed errCode = "game_start_failed"
codeHandshakeRequired errCode = "handshake_required"
codeKicked errCode = "kicked"
codeMustUnreadyFirst errCode = "must_unready_first"
codeNeedMorePlayers errCode = "need_more_players"
codeNoOneToKick errCode = "no_one_to_kick"
codeNotADeadEnd errCode = "not_a_dead_end"
codeNotEveryoneReady errCode = "not_everyone_ready"
codeNotInAGame errCode = "not_in_a_game"
codeNotInARoom errCode = "not_in_a_room"
codeNotTheOwner errCode = "not_the_owner"
codeNotYourSeat errCode = "not_your_seat"
codeNotYourTurn errCode = "not_your_turn"
codeOwnerNeedsNoReady errCode = "owner_needs_no_ready"
codePlayerIsReady errCode = "player_is_ready"
codePlayerOffline errCode = "player_offline"
codeProtocolVersionMismatch errCode = "protocol_version_mismatch"
codeRoomFull errCode = "room_full"
codeRoomIdleClosed errCode = "room_idle_closed"
codeRoomNotFound errCode = "room_not_found"
codeRoomStartFailed errCode = "room_start_failed"
codeServerFull errCode = "server_full"
codeServerRestarting errCode = "server_restarting"
codeSessionNotResumable errCode = "session_not_resumable"
codeTooFast errCode = "too_fast"
codeTooManyAttempts errCode = "too_many_attempts"
codeTooManyRooms errCode = "too_many_rooms"
codeUnknownMessage errCode = "unknown_message"
codeUnknownDifficulty errCode = "unknown_difficulty"
codeWordReportLimit errCode = "word_report_limit"
codeWordReportRefused errCode = "word_report_refused"
)