RTCMultiConnection Docs

RTCMultiConnection API Reference / "onstatechange" event

"onstatechange" is handy event to checkout what's going on. Which thing is missing or failed, etc.

Remember, older "onstats" event has been removed since v1.8.

Since v2.0, an "object" is passed over this event.

connection.onstatechange = function(state) {
    // state.userid == 'target-userid' || 'browser'
    // state.extra  == 'target-user-extra-data' || {}
    // state.name  == 'short name'
    // state.reason == 'longer description'
    if(state.name == 'stop-request-denied') {
        alert(state.reason);
    }
    
    if(state.name == 'mute-request-denied') {
        alert(state.reason);
    }
};

v1.9 or earlier

connection.onstatechange = function (state, reason) {
    // fetching-usermedia
    // usermedia-fetched

    // detecting-room-presence
    // room-not-available
    // room-available

    // connecting-with-initiator
    // connected-with-initiator

    // failed---has reason

    // request-accepted
    // request-rejected

    if(state == 'room-not-available') {
        // room no longer exist
    }
};

Want to ask a Question?

You can include your email for private conversation!

Latest Updates