WireStats: messagesIn property

Available since @irtio/client 5.0BrowsersNode

The messagesIn property of the WireStats interface is the number of protocol messages the client has received since it was created, across reconnects.

Value

A number, from 0. The client counts every message the router sends it: state updates, pongs, room messages, call replies and the rest. received splits it by message type.

Examples

Counting messages a second

A debug overlay shows how many messages arrive each second, which rises with the room’s tick rate and with what the client sees.

// messages-per-second.ts
import type { ReadyRoomClient } from "@irtio/client";

export function countMessages(room: ReadyRoomClient) {
  let last = room.stats.messagesIn;
  return setInterval(() => {
    console.log(`${room.stats.messagesIn - last} messages/s in`);
    last = room.stats.messagesIn;
  }, 1000);
}

See also

Runtime availability

BrowsersNode
messagesIn5.05.0