RoomClient: type property

Available since @irtio/client 5.0BrowsersNode

The type read-only property of the RoomClient interface is the room type the client expects the room to be of.

Value

A string: the type passed to connect() or the constructor, or "default" when it was left out.

Description

The client sends its type when it connects. A room of another type, or a type the live build doesn’t have, closes the connection with 4015, whose reason names the room’s type; reloading doesn’t fix it. A connection that creates its room creates it of this type.

A client from a handoff event has the type of the room it moved to.

Examples

Connecting to a room of another type

A match room is of the type match, so the client connecting to it by URL passes the type. The lobby is of the type default.

// match-type.ts
import { connect } from "@irtio/client";

const lobby = await connect("lobby");
console.log(lobby.type); // "default"
const match = await connect("match-17", { type: "match" });
console.log(match.type); // "match"

See also

Runtime availability

BrowsersNode
type5.05.0