RoomOpenEvent: reconnected property
Available since
@irtio/client 5.0BrowsersNodeThe reconnected read-only property of the RoomOpenEvent interface says whether the client had a connection to the room before this open event.
Value
A boolean.
falsefor the first open, which fires beforeconnect()resolves.trueafter each reconnect, whether the client resumed or the room sent its state whole.
Description
A listener added after await connect(...) sees only opens with reconnected true, since the first one has fired by then.
Examples
Telling a first join from a return
A listener added before the client is ready sees both kinds of open. The client is constructed with new RoomClient() rather than connect() so the listener is in place before the first one.
// join-log.ts
import { RoomClient } from "@irtio/client";
const client = new RoomClient("https://rooms.irt.io/my-game/arena");
client.addEventListener("open", (event) => {
console.log(event.reconnected ? "back in the arena" : "joined the arena");
});
await client.ready;
See also
Runtime availability
| Browsers | Node | |
|---|---|---|
reconnected | 5.0 | 5.0 |