RTCMultiConnection Docs

RTCMultiConnection API Reference / "ondisconnected" event

  1. "ondisconnected" event is fired as soon as peers connection is closed or dropped.
  2. connection.ondisconnected = function (event) {
        // event.userid
        // event.extra
        // event.peer
    }
    

Check if Host Left

connection.onconnected = function(event) {
    if (connection.isInitiator) return; // skip below code for Host

    if (!connection.connectedWithHost) {
        connection.connectedWithHost = true; // first user is always Host
        connection.peers[event.userid].isHost = true; // this boolean is checked in "ondisconnected" event.
    }
};

connection.ondisconnected = function(event) {
    if (connection.isInitiator) return; // skip below code for Host

    var remoteUser = connection.peers[event.userid];
    if (remoteUser.isHost) {
        alert('Room moderator or Host seems left.');
        connection.close(); // manually close connection with other participants (if there is anyone still connected)
        location.reload(); // or
    }
};

Latest Issues

Want to ask a Question?

You can include your email for private conversation!

Latest Updates