DocsGame integration

Multiplayer rooms

Choose a room model, configure it and connect players through the SDK.

Plan your rooms

Start with rooms_plan. Describe how many players share a match, whether they compete, and how they meet. The planner returns a suitable configuration or explains which limit the game exceeds.

MCP · rooms_plan arguments
{
  "players": {
    "min": 2,
    "max": 4
  },
  "competitive": false,
  "private": true,
  "lobby": true
}

Review the plan, then apply its payload with rooms_configure. Read the looping-multiplayer skill before adding online play.

Choose the right mode

ModeFitsGame code
RelayCo-op, social play and games where cheating gives no advantageClients exchange messages and shared state
AuthoritativeCompetitive, ranked or rewarded playThe build's rules.js validates inputs and runs the simulation

A relay room holds up to 32 players; an authoritative room holds up to 16. Named room kinds let a game combine different modes and match sizes. Existing rooms keep the policy they opened with.

Connect players

This relay example joins a public room after its policy is configured. Handle connection failures in your game's UI. The callbacks below are functions your game supplies.

JavaScript
const room = await looping.rooms.join("harbor-1", {
  max: 4,
  public: true,
});

room.on("message", ({ from, d }) => updatePlayer(from, d));
room.on("away", (id) => markReconnecting(id));
room.on("back", (id) => markConnected(id));
room.send({ x: 3, y: 4 });

// When the player leaves the match:
room.leave();

In authoritative mode, send room.input(data) and listen for view and result. Use rooms.create and rooms.joinInvite for private rooms, or rooms.match for matchmaking. Read each method's full contract through engine_docs.

Operate a game

rooms_status reports live players and rooms, queues, usage, available hosting credits and reports. Multiplayer consumes the project's hosting credits; previews use the available preview allowance first.

Use players_list to find a pseudonymous player ID and player_ban to moderate it. Set signed_in_only when room access and bans need to follow a player's account.

Before release, test with two browsers and disconnect one. The other should show the player as away, then back when the connection recovers.