WireStats: received property
Available since
@irtio/client 5.0BrowsersNodeThe received read-only property of the WireStats interface counts the messages and bytes the client has received since it was created, by server message type.
Value
An object whose keys are server message types and whose values are objects with these properties:
messages- The number of messages of the type received.
bytes- Their total size in bytes.
A type is a key once the client has received a message of it. The types include state (state updates), ack (input acks), pong, message, unreliable and reply (call replies).
Description
received.state.bytes is what state sync has cost, and the sum over every type is bytesIn.
Examples
Splitting download by type
A debug overlay lists each server message type with its share of the bytes received.
// download-split.ts
import type { ReadyRoomClient } from "@irtio/client";
export function downloadSplit(room: ReadyRoomClient) {
const total = room.stats.bytesIn || 1;
for (const [type, { messages, bytes }] of Object.entries(room.stats.received)) {
console.log(`${type}: ${messages} messages, ${Math.round((bytes / total) * 100)}%`);
}
}
See also
WireStats.sentWireStats.lastUpdate, for the size of one state update- State sync and interest
Runtime availability
| Browsers | Node | |
|---|---|---|
received | 5.0 | 5.0 |