Docs/Games/Connect 4
Games

Connect 4

Turn-based, 1v1. Same architecture as Checkers — this page covers what's genuinely different: the move shape and board dimensions.

Turn-based1v1Hosted: socket + REST

Session creation

json
{ "game": "connect4", "matchType": "matchmaking", "players": [{ "id": "user_1" }] }

Socket events

EventDirectionPayload
game:startedserver → client{ roomId, players, board, currentTurn, rows, cols, afkTimeoutEnabled, afkTimeoutSeconds, afkWarnSeconds, playerId, color: 'red'|'yellow' }
game:moveclient → server{ roomId, column: number, playerId }
game:move:madeserver → clientBroadcast after a valid move — full updated board + currentTurn
game:overserver → clientResult object, same shape as the game.ended webhook
connect4:afk_warning_clearedserver → clientFires when a player about to be AFK-forfeited moves in time

Board

Standard 7-column, 6-row board — confirm exact dimensions from the rows/cols fields on game:started rather than hardcoding 7×6, since they're sent dynamically rather than fixed constants.

js
socket.emit('game:move', { roomId, playerId, column: 3 }); // drops into column 3

AFK timeout

90 second timeout, 30 second warning — the default; not currently overridable via afkConfig for this game.

Hosted matchmaking

Supports hosted matchmaking via both direct socket events and the REST endpoints — same shape as Checkers.