RTCDataChannel: closing event

The closing event is sent to an RTCDataChannel just before the channel begins the process of shutting down its underlying data transport.

Bubbles No
Cancelable No
Interface Event
Event handler property RTCDataChannel.onclosing

Description

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.

Examples

This example updates a connection status interface when the closing event arrives.

First, an example using addEventListener():

dataChannel.addEventListener("closing", ev => {
  myConnectionStatus.icon = closingIcon;
  myConnectionStatus.text = "Connection closing";
});

You can also set the onclosing event handler property directly:

pc.onclosing = ev => {
 myConnectionStatus.icon = closingIcon;
 myConnectionStatus.text = "Connection closing";
};

Specifications

Specification Status Comment
WebRTC 1.0: Real-time Communication Between Browsers
The definition of 'RTCDataChannel: closing event' in that specification.
Candidate Recommendation

Browser compatibility

No compatibility data found. Please contribute data for "api.RTCDataChannel.closing_event" (depth: 1) to the MDN compatibility data repository.

See also