isInitiator | RTCMultiConnection

Readonly boolean that can be used to detect the room initiator/owner/moderator.

Usage

connection.onstream = function(event) {
    var isInitiator = connection.isInitiator;

    if (isInitiator === true && event.type === 'local') {
        // initiator's own stream
    }

    if (isInitiator === true && event.type === 'remote') {
        // initiator recieved stream from someone else
    }
};

Description

parameterdescription
isInitiator it is a readonly boolean

Demo

<script src="https://rtcmulticonnection.herokuapp.com/dist/RTCMultiConnection.min.js"></script>
<script src="https://rtcmulticonnection.herokuapp.com/socket.io/socket.io.js"></script>

<script>
var connection = new RTCMultiConnection();

// this line is VERY_important
connection.socketURL = 'https://rtcmulticonnection.herokuapp.com:443/';

// if you want audio+video conferencing
connection.session = {
    audio: true,
    video: true
};

connection.onstream = function(event) {
    var isInitiator = connection.isInitiator;

    if (isInitiator === true && event.type === 'local') {
        // initiator's own stream
        alert('you are initiator');
    }

    if (isInitiator === true && event.type === 'remote') {
        // initiator recieved stream from someone else
        alert('dear initiator, you just receive a remote stream');
    }

    document.body.appendChild(event.mediaElement);
};

connection.openOrJoin('your-room-id');
</script>