RTCMultiConnection Docs

RTCMultiConnection API Reference / "onSessionClosed" event

"onSessionClosed" event is fired when initiator closed the entire session.

Remember, "onleave" event also has a boolean parameter "event.entireSessionClosed" which is "true" only when entire session is closed.
connection.onSessionClosed = function(e) {
    // entire session is closed
    // e.userid
    // e.extra
    // e.isSessionClosed
    // e.session == connection.sessionDescription
    // e.session.sessionid
    // e.session.userid --- initiator id
    // e.session.session -- {audio:true, video:true}

// old-fashioned "onleave" to check if entire session is closed.
connection.onleave = function(e) {
    // e.entireSessionClosed --------- this boolean allows you identify initiator
    // e.userid
    // e.extra


  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 () {
}, 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