No description
Wire the WebSocket message handler to process game.move intents via GameSession and broadcast game.delta to both room players. Add broadcast.ts as the message router with handlers for room.create, room.join (triggers game.state to both players when 2nd player joins), room.leave, and game.move. Move-intent validation enforces NOT_YOUR_TURN before applyMove so clients can distinguish turn errors from illegal moves. index.ts now extends ClientData with roomCode/token, registers connections on open and unregisters (+ markDisconnected + broadcast game.end) on close, and gates inbound frames through the size cap and rate limiter before dispatch. broadcast.test.ts drives handleMessage directly with mock ServerWebSockets (vitest runs on Node, so we can't use Bun.serve) covering: legal-move broadcast to both players, illegal-move error-to-sender-only with silent opponent, NOT_YOUR_TURN, malformed JSON fatal disconnect, VERSION_MISMATCH fatal disconnect, ROOM_NOT_FOUND, and BAD_TOKEN for unauthenticated game.move. bun run typecheck, bun run lint, bun run test all pass. |
||
|---|---|---|
| .github/workflows | ||
| .sisyphus | ||
| docs | ||
| packages | ||
| scripts | ||
| .gitignore | ||
| eslint.config.js | ||
| lefthook.yml | ||
| LICENSE | ||
| package.json | ||
| playwright.config.ts | ||
| README.md | ||
| tsconfig.base.json | ||
| tsconfig.json | ||
| vitest.workspace.ts | ||
@paratype
A Doorenbos-style Rete II rules engine for TypeScript games, with an authoritative WebSocket chess demo.
Packages
packages/rete— Rete II engine corepackages/chess— Browser chess demo (React + Vite)packages/server— Authoritative Bun WebSocket server
Docs
- SPEC.md — Engine specification
- PHASES.md — Development phases & perf budgets
- RULES.md — Chess rule presets
- PROTOCOL.md — WebSocket message protocol
Getting Started
bun install && bun run check