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.
{
"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
| Mode | Fits | Game code |
|---|---|---|
| Relay | Co-op, social play and games where cheating gives no advantage | Clients exchange messages and shared state |
| Authoritative | Competitive, ranked or rewarded play | The 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.
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.