RTCMultiConnection Docs

RTCMultiConnection API Reference / "leaveOnPageUnload" boolean

"leaveOnPageUnload" boolean can be used to override RTCMultiConnection's default "leaving" behaviour. RTCMultiConnection usually listens for "onbeforeunload" event handler as well as "F5" key i.e. "onkeyup---event.keyCode=116". It auto invokes "connection.leave" method in both cases.
// if you want to prevent/override/bypass default behaviour
connection.leaveOnPageUnload = false;

// display a notification box
window.addEventListener("beforeunload", function (e) {
  var confirmationMessage = 'Are you want to leave?';

  (e || window.event).returnValue = confirmationMessage;     //Gecko + IE
  return confirmationMessage;                                //Webkit, Safari, Chrome etc.
});

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

Relevant API

  1. RTCMultiConnection.leave method.
  2. RTCMultiConnection.close method.
  3. RTCMultiConnection.eject method.
  4. RTCMultiConnection.autoCloseEntireSession boolean.

Want to ask a Question?

You can include your email for private conversation!

Latest Updates