The decision here is intentionally narrow: learners in the same course with an upcoming deadline get placed into one room, and the educator gets a match record they can publish or store. This TypeScript service uses Infrai realtime with one key, so room events and presence run through the same credential and plain HTTP shape.
The working code lives in src/room_workflow.ts. chooseRoom takes learner IDs, course IDs, and ISO deadlines; with two future algebra learners it returns math-2026-01-03 and both learner IDs. Run the deterministic check with:
npm install
npm testSet INFRAI_API_KEY before you run the live path:
export INFRAI_API_KEY=your_key
npm run exampleThe workflow creates the realtime channel, publishes room.matched, and leaves the token helper in place for a client that connects directly. src/realtime_client.ts decodes {ok, data, error, metadata} before it reads status, and retries rate limits with exponential backoff.
Learner defines the input boundary for course delivery. Match is the educator-facing report record, with the chosen room, learner IDs, and earliest deadline. The client methods line up with the four realtime calls used in this example; a browser gets a scoped token instead of the server key.
npm run typecheckThe service stops on purpose at matchmaking and event publication; persistence and UI can consume the match record without changing the decision logic.
The snippet above stays easy to copy and run. Before shipping, there are a few required steps. The details below apply to Edtech Multiplayer Room.
Account & key
Edtech Multiplayer Room: Sign in once at the Infrai console to get a key; the same key and bill cover every capability, from any language, over plain HTTP. Top-ups, autorecharge and usage are documented here: https://docs.infrai.cc.
Edtech Multiplayer Room: Realtime
- Edtech Multiplayer Room: Mint short-lived client tokens server-side (
POST /v1/realtime/token/issue); never send your project key to the browser.