Movatterモバイル変換


[0]ホーム

URL:


  1. Web
  2. Web APIs
  3. WebTransportReceiveStream
  4. getStats()

WebTransportReceiveStream: getStats() method

Limited availability

This feature is not Baseline because it does not work in some of the most widely-used browsers.

Experimental:This is anexperimental technology
Check theBrowser compatibility table carefully before using this in production.

Secure context: This feature is available only insecure contexts (HTTPS), in some or allsupporting browsers.

Note: This feature is available inWeb Workers.

ThegetStats() method of theWebTransportReceiveStream interface asynchronously returns an object containing statistics for the current stream.

The statistics include the total number of ordered bytes that have arrived on this stream (ignoring network overhead, up until the first missing byte) and the total number that have been read by the application.It therefore provides a measure of how quickly the application is consuming bytes from the server on this particular stream.

Syntax

js
getStats()

Parameters

None.

Return value

APromise that resolves to an object containing statistics about the current stream.The returned object has the following properties:

timestamp

ADOMHighResTimeStamp indicating 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 thisWebTransportReceiveStream stream.This number can only increase, and is always less than or equal tobytesReceived.

Examples

The code snippet below usesawait to wait on thePromise returned bygetStats().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

Browser compatibility

Help improve MDN

Learn how to contribute

This page was last modified on byMDN contributors.


[8]ページ先頭

©2009-2025 Movatter.jp