Skip to main content

Rooms

Rooms.list(): Promise<RoomsListResult | null>​

This deck's public multiplayer rooms and how many players are in each, for a lobby, a room picker or a "12 playing now" line. No room has to write its own count to Store for a menu to read.

import { Rooms } from "castle-web-sdk";

const list = await Rooms.list();
if (list) {
label.textContent = `${list.total} playing now`;
for (const room of list.rooms) {
// { sessionId, players, maxPlayers }
}
}
  • total is the players across every listed room; rooms is one entry per room.
  • It resolves null when Castle will not list the deck's rooms for this player. The deck's owner and Castle admins always get a list; whether other players do depends on how far Castle has rolled presence out, so handle null for any player. A player under 13, or one Castle keeps out of multiplayer, gets null even on their own deck. Treat null as "not available", never as "no rooms": a deck nobody is playing answers { total: 0, rooms: [] }.
  • An app built before the call also resolves null rather than throwing UNKNOWN_COMMAND. An unsaved deck throws MISSING_DECK_ID.
  • Counts come from a rollup Castle refreshes about every 10 seconds, so a player who joined or left in the last few seconds may not show yet. Poll it no more than every 10 seconds; there is no event.
  • Only public rooms are listed. Private, party and named rooms are not.
  • A local castle-web serve lists the saved deck's rooms on Castle, not the rooms of the local serve.