Movatterモバイル変換


[0]ホーム

URL:


MDN Web Docs

RTCDataChannel: bufferedAmount property

BaselineWidely available

The read-onlyRTCDataChannel propertybufferedAmount returns the number of bytes of datacurrently queued to be sent over the data channel. The queue may build up as aresult of calls to thesend() method. This onlyincludes data buffered by the user agent itself; it doesn't include any framing overheador buffering done by the operating system or network hardware.

The user agent may implement the process of actually sending data in any way itchooses; this may be done periodically during the event loop or truly asynchronously. Asmessages are actually sent, this value is reduced accordingly.

Note:Closing the data channel doesn't reset this count, even though the user agent purgesthe queued messages. However, even after closing the channel, attempts to sendmessages continue to add to thebufferedAmount value, even though themessages are neither sent nor buffered.

Whenever this value decreases to fall to or below the value specified in thebufferedAmountLowThresholdproperty, the user agent fires thebufferedamountlow event. This event maybe used, for example, to implement code which queues more messages to be sent wheneverthere's room to buffer them.

Value

The number of bytes of data currently queued to be sent over the data channel but havenot yet been sent.

Example

The snippet below includes a function which changes the contents of a block with the ID"bufferSize" to a string indicating the number of bytes currently buffered on anRTCDataChannel.

js
const dc = peerConnection.createDataChannel("File Transfer");// …function showBufferedAmount(channel) {  const el = document.getElementById("bufferSize");  el.innerText = `${channel.bufferedAmount} bytes`;}

Specifications

Specification
WebRTC: Real-Time Communication in Browsers
# dom-datachannel-bufferedamount

Browser compatibility

See also

Help improve MDN

Learn how to contribute.

This page was last modified on byMDN contributors.


[8]ページ先頭

©2009-2025 Movatter.jp