Ma Sói Socket Contract
Workflow
- Find server emits/listeners in
server/index.js. - Find client listeners/actions in
client/src/hooks/useGame.js. - Check UI consumers in
client/src/pages/*andclient/src/components/*. - Update
references/events.mdwhen the contract changes. - Preserve hidden-information boundaries in payloads.
- Verify with:
node --check server/index.jscd client && npm run build
Contract Rules
- Every server
socket.emitorio.to(...).emitused by gameplay must have a matching client listener unless intentionally one-way. - Every client
socket.emitaction must have a matching server handler. - Payload changes must be made server-first, then hook state, then UI.
- Reconnect/resume must re-emit enough state to rebuild the current screen.
- Do not expose all player roles to living non-spectator players before the game ends.
Common Files
- Server handlers:
server/index.js - Client socket setup:
client/src/hooks/useSocket.jsx - Client game contract/state:
client/src/hooks/useGame.js - Main routing by phase:
client/src/App.jsx
References
Load references/events.md when changing Socket.IO payloads or reconnect behavior.