WireStats: messagesOut property

Available since @irtio/client 5.0BrowsersNode

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

Value

A number, from 0. The client counts every message it sends: inputs, pings, owner writes, messages, calls and the hello of each connect. sent splits it by message type.

Examples

Checking that writes are batched

A drag that writes an owned entity on every pointer move still sends at most one write message a tick, or one every 16 ms in a room without ticks. The client logs how many messages it sent during a drag.

// drag-cost.ts
import type { ReadyRoomClient } from "@irtio/client";

export function measureDrag(room: ReadyRoomClient) {
  const before = room.stats.messagesOut;
  return () => console.log(`the drag sent ${room.stats.messagesOut - before} messages`);
}

Call measureDrag() when the drag starts, and the function it returns when it ends.

See also

Runtime availability

BrowsersNode
messagesOut5.05.0