WebRTC
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.
Syntax
Use the event name in EventTarget/addEventListener:
addEventListener("closing", (event) => { })
Alternatively, assign to the event handler property of the interface:
onclosing = (event) => { }
Event type
A generic Event.
Description
While the closing event is sent to the channel just before beginning to close the channel's data transport, the RTCDataChannel.close_event event is sent once the closing process is complete.
Examples
This example updates a connection status interface when the closing event arrives.
First, an example using EventTarget.addEventListener:
dataChannel.addEventListener("closing", (ev) => {
myConnectionStatus.icon = closingIcon;
myConnectionStatus.text = "Connection closing";
});
You can also set the onclosing event handler property directly (but note that this replaces other event listeners added using onclosing, if any):
dataChannel.onclosing = (ev) => {
myConnectionStatus.icon = closingIcon;
myConnectionStatus.text = "Connection closing";
};
Specifications
Browser compatibility
See also
来源:MDN Web Docs / Mozilla 贡献者 · 作者与贡献记录 · CC BY-SA 2.5。离线整理了版式、链接和媒体显示。
