The closing
event is sent to an RTCDataChannel
just before the channel begins the process of shutting down its underlying data transport.
This event is not cancelable and does not bubble.
The closing
event is sent to an RTCDataChannel
just before the channel begins the process of shutting down its underlying data transport.
This event is not cancelable and does not bubble.
Use the event name in methods like addEventListener()
, or set an event handler property.
js
addEventListener("closing", (event) => {}); onclosing = (event) => {};
A generic Event
.
While the closing
event is sent to the channel just before beginning to close the channel's data transport, the close
event is sent once the closing process is complete.
This example updates a connection status interface when the closing
event arrives.
First, an example using addEventListener()
:
js
dataChannel.addEventListener("closing", (ev) => { myConnectionStatus.icon = closingIcon; myConnectionStatus.text = "Connection closing"; });
You can also set the onclosing
event handler property directly:
js
pc.onclosing = (ev) => { myConnectionStatus.icon = closingIcon; myConnectionStatus.text = "Connection closing"; };
Specification |
---|
WebRTC: Real-Time Communication in Browsers # event-datachannel-closing |
WebRTC: Real-Time Communication in Browsers # dom-rtcdatachannel-onclosing |
Desktop | Mobile | |||||||||||
---|---|---|---|---|---|---|---|---|---|---|---|---|
Chrome | Edge | Firefox | Internet Explorer | Opera | Safari | WebView Android | Chrome Android | Firefox for Android | Opera Android | Safari on IOS | Samsung Internet | |
closing_event |
81 | 81 | No | No | 68 | 15.4 | 81 | 81 | No | 58 | 15.4 | 13.0 |
© 2005–2023 MDN contributors.
Licensed under the Creative Commons Attribution-ShareAlike License v2.5 or later.
https://developer.mozilla.org/en-US/docs/Web/API/RTCDataChannel/closing_event