checkPresence | RTCMultiConnection

Use this method to check if room exist.

Usage

connection.checkPresence('room-id', function(isRoomExist, roomid) {
    if (isRoomExist === true) {
        connection.join(roomid);
    } else {
        connection.open(roomid);
    }
});

Keep checking for room

// below method "checkRoom" keeps checking for room until joins it
(function checkRoom() {
    connection.checkPresence('your-room-id', function(isRoomExist, roomid) {
        if (isRoomExist === true) {
            connection.join(roomid);
            return;
        }

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

Description

parameterdescription
roomid API will match this string on socket.io server
callback A function gets two parameters:
1) "isRoomExist" which is a boolean
2) "roomid" which is a room-id string

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('room-id', function(isRoomExist, roomid) {
    if (isRoomExist === true) {
        connection.join(roomid);
    } else {
        connection.open(roomid);
    }
});
</script>