-
Notifications
You must be signed in to change notification settings - Fork 22.6k
New issue
Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.
By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.
Already on GitHub? Sign in to your account
RTCDataChannelStats - add docs #32498
Merged
Merged
Changes from all commits
Commits
Show all changes
4 commits
Select commit
Hold shift + click to select a range
File filter
Filter by extension
Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
There are no files selected for viewing
29 changes: 29 additions & 0 deletions
29
files/en-us/web/api/rtcdatachannelstats/bytesreceived/index.md
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,29 @@ | ||
--- | ||
title: "RTCDataChannelStats: bytesReceived property" | ||
short-title: bytesReceived | ||
slug: Web/API/RTCDataChannelStats/bytesReceived | ||
page-type: web-api-instance-property | ||
browser-compat: api.RTCStatsReport.type_data-channel.bytesReceived | ||
--- | ||
|
||
{{APIRef("WebRTC")}} | ||
|
||
The **`bytesReceived`** property of the {{domxref("RTCDataChannelStats")}} dictionary returns the total number of payload bytes received on the associated {{domxref("RTCDataChannel")}}. | ||
|
||
Note that non-payload bytes, such as those for framing and in headers, are not included. | ||
|
||
## Value | ||
|
||
A positive integer value indicating the total number of payload bytes received on the associated data channel. | ||
|
||
## Specifications | ||
|
||
{{Specifications}} | ||
|
||
## Browser compatibility | ||
|
||
{{Compat}} | ||
|
||
## See also | ||
|
||
- {{domxref("RTCDataChannel")}} |
29 changes: 29 additions & 0 deletions
29
files/en-us/web/api/rtcdatachannelstats/bytessent/index.md
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,29 @@ | ||
--- | ||
title: "RTCDataChannelStats: bytesSent property" | ||
short-title: bytesSent | ||
slug: Web/API/RTCDataChannelStats/bytesSent | ||
page-type: web-api-instance-property | ||
browser-compat: api.RTCStatsReport.type_data-channel.bytesSent | ||
--- | ||
|
||
{{APIRef("WebRTC")}} | ||
|
||
The **`bytesSent`** property of the {{domxref("RTCDataChannelStats")}} dictionary returns the total number of payload bytes sent on the associated {{domxref("RTCDataChannel")}}. | ||
|
||
Note that non-payload bytes, such as those for framing and in headers, are not included. | ||
|
||
## Value | ||
|
||
A positive integer value indicating the total number of payload bytes sent on the associated data channel. | ||
|
||
## Specifications | ||
|
||
{{Specifications}} | ||
|
||
## Browser compatibility | ||
|
||
{{Compat}} | ||
|
||
## See also | ||
|
||
- {{domxref("RTCDataChannel")}} |
25 changes: 25 additions & 0 deletions
25
files/en-us/web/api/rtcdatachannelstats/datachannelidentifier/index.md
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,25 @@ | ||
--- | ||
title: "RTCDataChannelStats: dataChannelIdentifier property" | ||
short-title: dataChannelIdentifier | ||
slug: Web/API/RTCDataChannelStats/dataChannelIdentifier | ||
page-type: web-api-instance-property | ||
browser-compat: api.RTCStatsReport.type_data-channel.dataChannelIdentifier | ||
--- | ||
|
||
{{APIRef("WebRTC")}} | ||
|
||
The **`dataChannelIdentifier`** property of the {{domxref("RTCDataChannelStats")}} dictionary containing the {{domxref("RTCDataChannel.id", "id")}} of the associated `RTCDataChannel` providing these statistics. | ||
|
||
Using the `dataChannelIdentifier`, you can correlate this statistics object to a particular {{domxref("RTCDataChannel")}}. | ||
|
||
## Value | ||
|
||
A string containing the same value as the {{domxref("RTCDataChannel.id")}} property of the associated data channel. | ||
|
||
## Specifications | ||
|
||
{{Specifications}} | ||
|
||
## Browser compatibility | ||
|
||
{{Compat}} |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,27 @@ | ||
--- | ||
title: "RTCDataChannelStats: id property" | ||
short-title: id | ||
slug: Web/API/RTCDataChannelStats/id | ||
page-type: web-api-instance-property | ||
browser-compat: api.RTCStatsReport.type_data-channel.id | ||
--- | ||
|
||
{{APIRef("WebRTC")}} | ||
|
||
The **`id`** property of the {{domxref("RTCDataChannelStats")}} dictionary is a string that uniquely identifies the object for which this object provides statistics. | ||
|
||
Using the `id`, you can correlate this statistics object with others, in order to monitor statistics over time for a given WebRTC object, such as an {{domxref("RTCPeerConnection")}}, or an {{domxref("RTCDataChannel")}}. | ||
|
||
## Value | ||
|
||
A string that uniquely identifies the object for which this `RTCDataChannelStats` object provides statistics. | ||
|
||
The format of the ID string is not defined by the specification, so you cannot reliably make any assumptions about the contents of the string, or assume that the format of the string will remain unchanged for a given object type. | ||
|
||
## Specifications | ||
|
||
{{Specifications}} | ||
|
||
## Browser compatibility | ||
|
||
{{Compat}} |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,70 @@ | ||
--- | ||
title: RTCDataChannelStats | ||
slug: Web/API/RTCDataChannelStats | ||
page-type: web-api-interface | ||
browser-compat: api.RTCStatsReport.type_data-channel | ||
--- | ||
|
||
{{DefaultAPISidebar("WebRTC")}} | ||
|
||
The **`RTCDataChannelStats`** dictionary of the [WebRTC API](/en-US/docs/Web/API/WebRTC_API) provides statistics related to one {{domxref("RTCDataChannel")}} object on the connection. | ||
|
||
The report can be obtained by iterating the {{domxref("RTCStatsReport")}} returned by {{domxref("RTCPeerConnection.getStats()")}} until you find an entry with the [`type`](#type) of `data-channel`. | ||
|
||
The data channels statistics may be correlated to a particular channel by comparing the [`dataChannelIdentifier`](#datachannelidentifier) property to a matching {{domxref("RTCDataChannel.id")}}. | ||
|
||
## Instance properties | ||
|
||
- {{domxref("RTCDataChannelStats.bytesSent", "bytesSent")}} {{optional_inline}} | ||
- : A positive integer value indicating the total number of payload bytes sent on the associated `RTCDataChannel`. | ||
- {{domxref("RTCDataChannelStats.bytesReceived", "bytesReceived")}} {{optional_inline}} | ||
- : A positive integer value indicating the total number of payload bytes received on the associated `RTCDataChannel`. | ||
- {{domxref("RTCDataChannelStats.dataChannelIdentifier", "dataChannelIdentifier")}} {{optional_inline}} | ||
- : A positive integer value containing the {{domxref("RTCDataChannel.id", "id")}} of the associated `RTCDataChannel`. | ||
- {{domxref("RTCDataChannelStats.label", "label")}} {{optional_inline}} | ||
- : A string containing the {{domxref("RTCDataChannel.label", "label")}} of the associated `RTCDataChannel`. | ||
- {{domxref("RTCDataChannelStats.messagesReceived", "messagesReceived")}} {{optional_inline}} | ||
- : A positive integer value indicating the total number of [`message` events](/en-US/docs/Web/API/RTCDataChannel/message_event) fired for received messages on the associated `RTCDataChannel`. | ||
- {{domxref("RTCDataChannelStats.messagesSent", "messagesSent")}} {{optional_inline}} | ||
- : A positive integer value indicating the total number of [`message` events](/en-US/docs/Web/API/RTCDataChannel/message_event) fired for sent messages on the channel. | ||
- {{domxref("RTCDataChannelStats.protocol", "protocol")}} {{optional_inline}} | ||
- : A string containing the {{domxref("RTCDataChannel.protocol", "protocol")}} of the associated `RTCDataChannel`. | ||
- {{domxref("RTCDataChannelStats.state", "state")}} | ||
- : The {{domxref("RTCDataChannel.readyState", "readyState")}} of the associated `RTCDataChannel`. | ||
|
||
### Common instance properties | ||
|
||
The following properties are common to all WebRTC statistics objects (See [`RTCStatsReport`](/en-US/docs/Web/API/RTCStatsReport#common_instance_properties) for more information). | ||
|
||
<!-- RTCStats --> | ||
|
||
- {{domxref("RTCDataChannelStats.id", "id")}} | ||
- : A string that uniquely identifies the object that is being monitored to produce this set of statistics. | ||
- {{domxref("RTCDataChannelStats.timestamp", "timestamp")}} | ||
- : A {{domxref("DOMHighResTimeStamp")}} object indicating the time at which the sample was taken for this statistics object. | ||
- {{domxref("RTCDataChannelStats.type", "type")}} | ||
- : A string with the value `"data-channel"`, indicating the type of statistics that the object contains. | ||
|
||
## Examples | ||
|
||
Given a variable `myPeerConnection`, which is an instance of {{domxref("RTCPeerConnection")}}, the code below uses `await` to wait for the statistics report, and then iterates it using `RTCStatsReport.forEach()`. | ||
It then filters the dictionaries for just those reports that have the type of `data-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 | ||
|
||
{{Specifications}} | ||
|
||
## Browser compatibility | ||
|
||
{{Compat}} |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,29 @@ | ||
--- | ||
title: "RTCDataChannelStats: label property" | ||
short-title: label | ||
slug: Web/API/RTCDataChannelStats/label | ||
page-type: web-api-instance-property | ||
browser-compat: api.RTCStatsReport.type_data-channel.label | ||
--- | ||
|
||
{{APIRef("WebRTC")}} | ||
|
||
The **`label`** property of the {{domxref("RTCDataChannelStats")}} dictionary returns the {{domxref("RTCDataChannel.label", "label")}} of the associated data channel. | ||
|
||
The value of the label need not be unique, and its meaning is defined by the website or app when it creates the data channel. | ||
|
||
## Value | ||
|
||
A string containing the same value as the {{domxref("RTCDataChannel.label")}} property of the associated data channel. | ||
|
||
## Specifications | ||
|
||
{{Specifications}} | ||
|
||
## Browser compatibility | ||
|
||
{{Compat}} | ||
|
||
## See also | ||
|
||
- {{domxref("RTCDataChannel.label")}} |
23 changes: 23 additions & 0 deletions
23
files/en-us/web/api/rtcdatachannelstats/messagesreceived/index.md
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,23 @@ | ||
--- | ||
title: "RTCDataChannelStats: messagesReceived property" | ||
short-title: messagesReceived | ||
slug: Web/API/RTCDataChannelStats/messagesReceived | ||
page-type: web-api-instance-property | ||
browser-compat: api.RTCStatsReport.type_data-channel.messagesReceived | ||
--- | ||
|
||
{{APIRef("WebRTC")}} | ||
|
||
The **`messagesReceived`** property of the {{domxref("RTCDataChannelStats")}} dictionary returns the total number of [`message` events](/en-US/docs/Web/API/RTCDataChannel/message_event) fired for received messages on the associated {{domxref("RTCDataChannel")}}. | ||
|
||
## Value | ||
|
||
A positive integer value indicating the total number of `message` events for inbound data on the associated data channel. | ||
|
||
## Specifications | ||
|
||
{{Specifications}} | ||
|
||
## Browser compatibility | ||
|
||
{{Compat}} |
23 changes: 23 additions & 0 deletions
23
files/en-us/web/api/rtcdatachannelstats/messagessent/index.md
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,23 @@ | ||
--- | ||
title: "RTCDataChannelStats: messagesSent property" | ||
short-title: messagesSent | ||
slug: Web/API/RTCDataChannelStats/messagesSent | ||
page-type: web-api-instance-property | ||
browser-compat: api.RTCStatsReport.type_data-channel.messagesSent | ||
--- | ||
|
||
{{APIRef("WebRTC")}} | ||
|
||
The **`messagesSent`** property of the {{domxref("RTCDataChannelStats")}} dictionary returns the total number of [`message` events](/en-US/docs/Web/API/RTCDataChannel/message_event) fired for sent messages on the associated {{domxref("RTCDataChannel")}}. | ||
|
||
## Value | ||
|
||
A positive integer value indicating the total number of `message` events for outbound data on the the associated data channel. | ||
|
||
## Specifications | ||
|
||
{{Specifications}} | ||
|
||
## Browser compatibility | ||
|
||
{{Compat}} |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,31 @@ | ||
--- | ||
title: "RTCDataChannelStats: protocol property" | ||
short-title: protocol | ||
slug: Web/API/RTCDataChannelStats/protocol | ||
page-type: web-api-instance-property | ||
browser-compat: api.RTCStatsReport.type_data-channel.protocol | ||
--- | ||
|
||
{{APIRef("WebRTC")}} | ||
|
||
The **`protocol`** property of the {{domxref("RTCDataChannelStats")}} dictionary returns a string containing the {{domxref("RTCDataChannel.protocol", "protocol")}} of the associated data channel. | ||
|
||
The value is defined by the website or app when it creates the data channel. | ||
|
||
## Value | ||
|
||
A string containing the same value as the {{domxref("RTCDataChannel.protocol")}} property of the associated data channel. | ||
|
||
If no protocol was defined, this will be the empty string (""). | ||
|
||
## Specifications | ||
|
||
{{Specifications}} | ||
|
||
## Browser compatibility | ||
|
||
{{Compat}} | ||
|
||
## See also | ||
|
||
- {{domxref("RTCDataChannel.protocol")}} |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,29 @@ | ||
--- | ||
title: "RTCDataChannelStats: state property" | ||
short-title: state | ||
slug: Web/API/RTCDataChannelStats/state | ||
page-type: web-api-instance-property | ||
browser-compat: api.RTCStatsReport.type_data-channel.state | ||
--- | ||
|
||
{{APIRef("WebRTC")}} | ||
|
||
The **`state`** property of the `RTCDataChannelStats` dictionary returns a string that indicates the {{domxref("RTCDataChannel.readyState","readyState")}} of the data channel's underlying data connection: `connecting`, `open`, `closing` or `closed`. | ||
|
||
Note that this property is required. | ||
|
||
## Values | ||
|
||
A string containing the same value as the {{domxref("RTCDataChannel.readyState")}} property of the associated data channel. | ||
|
||
## Specifications | ||
|
||
{{Specifications}} | ||
|
||
## Browser compatibility | ||
|
||
{{Compat}} | ||
|
||
## See also | ||
|
||
- {{domxref("RTCDataChannel.readyState")}} |
25 changes: 25 additions & 0 deletions
25
files/en-us/web/api/rtcdatachannelstats/timestamp/index.md
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,25 @@ | ||
--- | ||
title: "RTCDataChannelStats: timestamp property" | ||
short-title: timestamp | ||
slug: Web/API/RTCDataChannelStats/timestamp | ||
page-type: web-api-instance-property | ||
browser-compat: api.RTCStatsReport.type_data-channel.timestamp | ||
--- | ||
|
||
{{APIRef("WebRTC")}} | ||
|
||
The **`timestamp`** property of the {{domxref("RTCDataChannelStats")}} dictionary is a {{domxref("DOMHighResTimeStamp")}} object specifying the time at which the data in the object was sampled. | ||
|
||
## Value | ||
|
||
A {{domxref("DOMHighResTimeStamp")}} value indicating the time at which the activity described by the statistics in this object was recorded, in milliseconds elapsed since the beginning of January 1, 1970, UTC. | ||
|
||
The value should be accurate to within a few milliseconds but may not be entirely precise, either because of hardware or operating system limitations or because of [fingerprinting](/en-US/docs/Glossary/Fingerprinting) protection in the form of reduced clock precision or accuracy. | ||
|
||
## Specifications | ||
|
||
{{Specifications}} | ||
|
||
## Browser compatibility | ||
|
||
{{Compat}} |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,27 @@ | ||
--- | ||
title: "RTCDataChannelStats: type property" | ||
short-title: type | ||
slug: Web/API/RTCDataChannelStats/type | ||
page-type: web-api-instance-property | ||
browser-compat: api.RTCStatsReport.type_data-channel.type | ||
--- | ||
|
||
{{APIRef("WebRTC")}} | ||
|
||
The **`type`** property of the {{domxref("RTCDataChannelStats")}} dictionary is a string with the value `"data-channel"`. | ||
|
||
Different statistics are obtained by iterating the {{domxref("RTCStatsReport")}} object returned by a call to {{domxref("RTCPeerConnection.getStats()")}}. | ||
The type indicates the set of statistics available through the object in a particular iteration step. | ||
A value of `"data-channel"` indicates that the statistics available in the current step are those defined in {{domxref("RTCDataChannelStats")}}. | ||
|
||
## Value | ||
|
||
A string with the value `"data-channel"`. | ||
|
||
## Specifications | ||
|
||
{{Specifications}} | ||
|
||
## Browser compatibility | ||
|
||
{{Compat}} |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Add this suggestion to a batch that can be applied as a single commit.
This suggestion is invalid because no changes were made to the code.
Suggestions cannot be applied while the pull request is closed.
Suggestions cannot be applied while viewing a subset of changes.
Only one suggestion per line can be applied in a batch.
Add this suggestion to a batch that can be applied as a single commit.
Applying suggestions on deleted lines is not supported.
You must change the existing code in this line in order to create a valid suggestion.
Outdated suggestions cannot be applied.
This suggestion has been applied or marked resolved.
Suggestions cannot be applied from pending reviews.
Suggestions cannot be applied on multi-line comments.
Suggestions cannot be applied while the pull request is queued to merge.
Suggestion cannot be applied right now. Please check back later.
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
FYI This is marked as
required
in the IDL, as are the common properties below. The rest are not, and are therefore optional. I've marked those as optional inline here for the other ones, but how should I mark up the detailed property docs as there is no "Optional header" macro?The whole thing is a bit odd because this isn't like a dictionary passed as an argument - the
required
is more an instruction to the browser vendor that they are expected to provide the information rather than to users.There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
I would just leave this. As you say it is a weird case.