openOrJoin | RTCMultiConnection

Open if room does not exist, otherwise join it.

Usage

connection.openOrJoin('room-id');

Description

parameterdescription
roomid it is a string
callback it is an optional function callback
connection.openOrJoin('room-id', function() {
    if (connection.isInitiator === true) {
        // you opened the room
    } else {
        // you joined it
    }
});

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.openOrJoin('your-room-id');
</script>