Use this method to check if a room is active and has participants
connection.checkPresence('room-id', function(isRoomExist, roomid, error) { if (isRoomExist === true) { connection.join(roomid); } else { connection.open(roomid); } });
// below method "checkRoom" keeps checking for room until joins it (function checkRoom() { connection.checkPresence('your-room-id', function(isRoomExist, roomid, error) { if (isRoomExist === true) { connection.join(roomid); return; } setTimeout(checkRoom, 3000); // recheck after every 3 seconds }); })();
parameter | description |
---|---|
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 |
<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>