Skip to content
PEERLESSDocs

Relay rooms

Exchange small events between up to 16 players without running a backend.

How relay rooms work

A relay room forwards small JSON events between players. It does not simulate anything: your game decides who owns each rule and validates every event it receives. Rooms hold up to 16 players and each event must stay under 16 KiB.

Enable Multiplayer (Peerless rooms) on the build and set the room cap to the player count you have tested.

Join when the launch has a room

init() reports a room when the player opened a room link or joined through a party. Listen for events before joining:

const stopEvents = Peerless.on("event", (event) => {
  // event.sender is set by the relay; never trust a sender inside the payload.
  if (event.name === "move") movePeer(event.sender, event.data);
});
const context = await Peerless.init();
if (context.room) await Peerless.join(context.room);

Peerless.send({ name: "move", data: { x: 1, y: 2 } });
// On shutdown: stopEvents(); Peerless.leave();

Events

EventValue
eventA relayed event with sender.
presenceThe room roster changed.
disconnectThe connection closed; the SDK retries with backoff.
errorA connection or message error.

Rooms for players

Inside the player, a multiplayer relay game offers Create room (a ten-character code), Join room and Copy room link. Parties can launch into the same room together. A rejected or expired launch closes the room connection instead of reconnecting.