RoomClient: protocol property

Available since @irtio/client 5.0BrowsersNode

The protocol read-only property of the RoomClient interface is the version of the client protocol the connection speaks.

Value

A number: the newest version the client, the router and the room all speak, from the router’s answer to each connection. It’s 0 until the router accepts the first connection.

Description

A router or room that doesn’t speak a version this client accepts closes the connection with 4000; update @irtio/client. The room sees the same version as connection.protocol.

Examples

Logging the protocol on connect

A client logs the protocol version the room speaks once it’s connected.

// protocol.ts
import { connect } from "@irtio/client";

const room = await connect("main");
console.log(`room ${room.id} speaks client protocol ${room.protocol}`);

See also

Runtime availability

BrowsersNode
protocol5.05.0