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 }
}
}
totalis the players across every listed room;roomsis one entry per room.- It resolves
nullwhen 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 handlenullfor any player. A player under 13, or one Castle keeps out of multiplayer, getsnulleven on their own deck. Treatnullas "not available", never as "no rooms": a deck nobody is playing answers{ total: 0, rooms: [] }. - An app built before the call also resolves
nullrather than throwingUNKNOWN_COMMAND. An unsaved deck throwsMISSING_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 servelists the saved deck's rooms on Castle, not the rooms of the local serve.