Presence: size property
Available since
@irtio/room 0.1Hosted roomsirt dev@irtio/testingSelf-hosted room hostThe size read-only property of the Presence interface is the number of presence entries in the room.
Value
A whole number, at most MAX_PRESENCE (1,024). It counts every entry: players whose connection dropped and whose grace hasn’t ended, with connected false, and bots.
Description
size counts players, not connections: room.connections.size counts the open connections, and a player in its grace has none.
Examples
Starting a match once four players are in
// start.ts
import { defineRoom } from "@irtio/room";
export default defineRoom({
data: () => ({ started: false }),
onJoin(room) {
if (room.data.started || room.presence.size < 4) return;
room.data.started = true;
room.broadcast({ type: "start" });
},
});
See also
Runtime availability
| Hosted rooms | irt dev | @irtio/testing | Self-hosted room host | |
|---|---|---|---|---|
size | 0.1 | 0.1 | 0.1 | 0.1 |