MenuMenu

RTCMultiConnection.open

Use this methodto create rooms

Usage

connection.open('room-id');

// this one is recommended
connection.open('room-id', function(isRoomOpened, roomid, error) {
    if(error) {
        alert(error);
    }

    if(isRoomOpened === true) {
        alert('Successfully created the room.');
    }
});

Best practice

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

Description

parameterdescription
roomid it is a string
callback it is an optional function callback
connection.open('room-id', function() {
    // open callback
});

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
};

btnJoinRoom.onclick = function() {
    connection.join('room-id', function(isRoomJoined, roomid, error) {
        if(error) {
            alert(error);
        }

        if(isRoomJoined === true) {
            alert('Successfully joined the room.');
        }
    });
};

btnOpenRoom.onclick = function() {
    connection.open('room-id', function(isRoomOpened, roomid, error) {
        if(error) {
            alert(error);
        }

        if(isRoomOpened === true) {
            alert('Successfully created the room.');
        }
    });
};
</script>