Checkers
Turn-based, 1v1. The reference implementation for the discrete-move architecture โ Tic-tac-toe and Connect 4 follow the same shape.
Session creation
{ "game": "checkers", "matchType": "matchmaking", "players": [{ "id": "user_1" }] }No game-specific session properties. afkConfig and gameRules aren't registered for this game yet โ see each page's own honesty note.
Types
type Player = 'red' | 'black';
type PieceType = 'man' | 'king';
interface Piece { player: Player; type: PieceType; }
type Cell = Piece | null;
type Board = Cell[]; // flat array, index 0-31 (32 playable dark squares)
interface Move {
from: number;
to: number;
captures?: number[]; // indices of captured pieces, if any
}Connect and join matchmaking
const socket = io('https://api.beta-gamer.com/checkers', { auth: { token }, autoConnect: false });
socket.connect();
socket.on('connect', () => {
socket.emit('matchmaking:join', { playerId, username: 'Alex' });
});Socket events
| Event | Direction | Payload |
|---|---|---|
game:started | server โ client | { roomId, players, board, currentTurn, afkTimeoutEnabled, afkTimeoutSeconds, playerId, color: 'red'|'black' } |
game:get_moves | client โ server | { roomId, index: number } |
game:valid_moves | server โ client | { index, moves: Move[] } |
game:move | client โ server | { roomId, move: Move, playerId } |
game:move:made | server โ client | Broadcast to the room after a valid move โ full updated board + currentTurn |
game:over | server โ client | { winner, isDraw, reason } |
checkers:afk_warning_cleared | server โ client | Fires when a player who was about to be AFK-forfeited moves in time |
Making a move
socket.emit('game:move', { roomId, playerId, move: { from: 12, to: 16, captures: [8] } });
socket.on('error', ({ message }) => {
// "Not your turn", "Room not found", "Game is not in progress"
});Try it
Click a piece, then a highlighted square โ watch the exact events on the right, live.
Click a piece on turn's color, then a highlighted square. Simplified rules โ diagonal steps only, no forced captures โ this teaches the wire protocol, not tournament checkers.
AFK timeout
90 second timeout, 60 second warning โ hardcoded for this game, not currently overridable via afkConfig.
Hosted matchmaking
Checkers supports hosted matchmaking via both direct socket events and the REST endpoints documented under Hosted Matchmaking. Either path works identically.
socket.emit('hosted:submit_group', { playerIds: ['user_1', 'user_2'] });
socket.on('hosted:group_submitted', ({ groupId }) => { /* ... */ });
socket.emit('hosted:start_match', { groupIds: [groupId] });
socket.on('hosted:match_started', () => { /* game:started follows */ });matchmaking:join_group also exists as a socket event, alongside the plain matchmaking:joinshown above โ for grouping specific players before they enter the general queue. If your integration doesn't need that, the simple join above is all you need.