Syntax
js
getStats()
Parameters
None.
Return value
A Promise that resolves to an object containing statistics about the current stream.
The returned object has the following properties:
timestamp-
A
DOMHighResTimeStampindicating the timestamp at which the statistics were gathered, relative to Jan 1, 1970, UTC. bytesReceived-
A positive integer indicating the number of bytes received by this stream, up to the first missing byte. The number does not include any network overhead, and can only increase.
bytesRead-
A positive integer indicating the number of bytes the application has read from this
WebTransportReceiveStreamstream. This number can only increase, and is always less than or equal tobytesReceived.
Examples
The code snippet below uses await to wait on the Promise returned by getStats().
When the promise fulfills, the number of bytes that have not yet been read is logged to the console.
js
const stats = await stream.getStats();
const unConsumedBytes = stats.bytesReceived - stats.bytesRead;
console.log(`Bytes in reader queue: ${unConsumedBytes}`);
Specifications
| Specification |
|---|
| WebTransport # dom-webtransportreceivestream-getstats |