RTCMultiConnection Docs

RTCMultiConnection API Reference / "leave" method

"leave" method can be invoked both for initiator and participants however usually it is invoked only for participants. This method is invoked on-page-unload however you can easily prevent auto invocation of "leave" method by setting "connection.leaveOnPageUnload=false" boolean.

// or
connection.onstatechange = function (state) {
    if(state == 'connected-with-initiator') {
        document.getElementById('leave-session').disabled = false;

document.getElementById('leave-session').onclick = function() {

How to prevent auto leave?

// if you want to prevent default behaviour
connection.leaveOnPageUnload = false;

// display a notification box
window.addEventListener('beforeunload', function () {
    return 'Are you want to leave?';
}, false);

// leave here
window.addEventListener('unload', function () {
}, false);

Relevant API

  1. close method.
  2. eject method.
  3. autoCloseEntireSession object.

Want to ask a Question?

You can include your email for private conversation!

Latest Updates