RoomClient: joinTime property
Available since
@irtio/client 5.0BrowsersNodeThe joinTime read-only property of the RoomClient interface is how long the client took to join the room, and whether the room had to start first.
Value
An object with these properties, or undefined until ready resolves:
ms- A number: the milliseconds from constructing the client to applying the room’s first full state update. After a reconnect, it’s the milliseconds from the drop to the client holding the room’s state again.
started- A boolean:
trueif the router sent awakingevent on the way, which it does for a room that wakes from hibernation, a room the connection creates and a room that restarts after a crash.
Description
ms leaves out any createRoom() or quickJoin() before the client was constructed. The UI kit’s join loader shows it.
Examples
Recording join times
The game sends each join’s time to its own analytics, split by whether the room had to start, since a wake takes longer.
// join-metrics.ts
import { connect } from "@irtio/client";
const room = await connect("main");
const { ms, started } = room.joinTime ?? { ms: 0, started: false };
console.log(`joined in ${Math.round(ms)} ms${started ? ", room started" : ""}`);
room.addEventListener("open", () => {
if (room.joinTime) console.log(`back in ${Math.round(room.joinTime.ms)} ms`);
});
See also
wakingevent- UI kit, whose join loader shows it
Runtime availability
| Browsers | Node | |
|---|---|---|
joinTime | 5.0 | 5.0 |