Movatterモバイル変換


[0]ホーム

URL:


MDN Web Docs

RTCDataChannelStats

Limited availability

TheRTCDataChannelStats dictionary of theWebRTC API provides statistics related to oneRTCDataChannel object on the connection.

The report can be obtained by iterating theRTCStatsReport returned byRTCPeerConnection.getStats() until you find an entry with thetype ofdata-channel.

The data channels statistics may be correlated to a particular channel by comparing thedataChannelIdentifier property to a matchingRTCDataChannel.id.

Instance properties

bytesSentOptional

A positive integer value indicating the total number of payload bytes sent on the associatedRTCDataChannel.

bytesReceivedOptional

A positive integer value indicating the total number of payload bytes received on the associatedRTCDataChannel.

dataChannelIdentifierOptional

A positive integer value containing theid of the associatedRTCDataChannel.

labelOptional

A string containing thelabel of the associatedRTCDataChannel.

messagesReceivedOptional

A positive integer value indicating the total number ofmessage events fired for received messages on the associatedRTCDataChannel.

messagesSentOptional

A positive integer value indicating the total number ofmessage events fired for sent messages on the channel.

protocolOptional

A string containing theprotocol of the associatedRTCDataChannel.

state

ThereadyState of the associatedRTCDataChannel.

Common instance properties

The following properties are common to all WebRTC statistics objects (SeeRTCStatsReport for more information).

id

A string that uniquely identifies the object that is being monitored to produce this set of statistics.

timestamp

ADOMHighResTimeStamp object indicating the time at which the sample was taken for this statistics object.

type

A string with the value"data-channel", indicating the type of statistics that the object contains.

Examples

Given a variablemyPeerConnection, which is an instance ofRTCPeerConnection, the code below usesawait to wait for the statistics report, and then iterates it usingRTCStatsReport.forEach().It then filters the dictionaries for just those reports that have the type ofdata-channel and logs the result.

js
const stats = await myPeerConnection.getStats();stats.forEach((report) => {  if (report.type === "data-channel") {    // Log the channel information    console.log(report);  }});

Specifications

Specification
Identifiers for WebRTC's Statistics API
# dom-rtcstatstype-data-channel

Browser compatibility

Help improve MDN

Learn how to contribute.

This page was last modified on byMDN contributors.


[8]ページ先頭

©2009-2025 Movatter.jp