RTCDataChannel: closing event

Experimental: This is an experimental technology
Check the Browser compatibility table carefully before using this in production.

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 methods like addEventListener(), or set an event handler property.

addEventListener('bufferedamountlow', event => { });

onbufferedamountlow = 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 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

No specification found

No specification data found for api.RTCDataChannel.closing_event.
Check for problems with this page or contribute a missing spec_url to mdn/browser-compat-data. Also make sure the specification is included in w3c/browser-specs.

Browser compatibility

No compatibility data found for api.RTCDataChannel.closing_event.
Check for problems with this page or contribute missing data to mdn/browser-compat-data.

See also