RTCMultiConnection Docs

RTCMultiConnection API Reference / "onleave" event

"onleave" is fired both for initiator and participants. "Event.entireSessionClosed" boolean allows you check if initiator left.
connection.onleave = function(e) {
    // e.entireSessionClosed --------- this boolean allows you identify initiator
    // e.userid
    // e.extra
};

Scenarios:

  1. onleave will be fired if a user leaves using leave method.
  2. onleave will be fired if a user closed a session using close method.
  3. onleave will be fired if a user is ejected using eject method.
  4. onleave will be fired if a user closes the tab/window; or reloads the page.

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 () {
    connection.leave();
}, 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