getPublicModerators | RTCMultiConnection

This method allows you access all public rooms.

Usage

// below method "checkRoom" keeps checking for public rooms
(function checkRoom() {
    connection.getPublicModerators(function(owners) {
        owners.forEach(function(owner) {
            var roomid = owner.userid; // + owner.extra
            connection.join(roomid);
        });

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

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>