WireStats: bytesOut property
Available since
@irtio/client 5.0BrowsersNodeThe bytesOut property of the WireStats interface is the total size, in bytes, of the protocol messages the client has sent since it was created, across reconnects.
Value
A number of bytes, from 0. Sizes are of protocol messages as encoded, without the transport’s own framing, such as a WebSocket frame header.
Examples
Measuring upload over a match
At the end of a match, the client logs the average upload rate, which a predicting client spends mostly on inputs.
// match-upload.ts
import type { ReadyRoomClient } from "@irtio/client";
export function startMatch(room: ReadyRoomClient) {
const start = { bytes: room.stats.bytesOut, ms: performance.now() };
return () => {
const seconds = (performance.now() - start.ms) / 1000;
console.log(`${((room.stats.bytesOut - start.bytes) / seconds).toFixed(0)} B/s up`);
};
}
See also
WireStats.sent, for the bytes by message typeWireStats.bytesIn- Compact inputs
Runtime availability
| Browsers | Node | |
|---|---|---|
bytesOut | 5.0 | 5.0 |