becomePublicModerator | RTCMultiConnection

All rooms are "private" by default.

This method allows you publicize your room.

Other users can access public-rooms using getPublicModerators method.

Usage

connection.checkPresence('room-id', function(isRoomExist, roomid) {
    if (isRoomExist === false) {
        connection.open(roomid, true); // check the second parameter
    }
});

btnBecomeModeratorInALiveSession.onclick = function() {
    // use this method only for participants
    // participants that are asked to open new room
    connection.becomePublicModerator();
};

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.checkPresence('your-room-id', function(isRoomExist, roomid) {
    if (isRoomExist === false) {
        connection.open(roomid, true); // check the second parameter
    }
});

// below method "checkRoom" keeps checking for public rooms
(function checkRoom() {
    connection.getPublicModerators(function(owners) {
        if (connection.isInitiator === true) return;

        owners.forEach(function(owner) {
            var roomid = owner.userid; // + owner.extra
            connection.join(roomid);
        });

        setTimeout(checkRoom, 3000); // recheck after every 3 seconds
    });
})();
</script>