Open nasr18 opened 8 years ago
v3 users can use checkPresence
method:
<button id="btn-join-room" disabled></button>
<script>
connection.checkPresence('room-id', function(isRoomExists, roomid) {
if (isRoomExists === false) {
document.querySelector('#btn-join-room').disabled = true;
} else {
document.querySelector('#btn-join-room').disabled = false;
}
});
</script>
And v2 users can use sendCustomMessage
:
<button id="btn-join-room" disabled></button>
<script>
var isRoomOpened = false;
connection.onCustomMessage = function(message) {
if (message.isRoomExists === false) {
document.querySelector('#btn-join-room').disabled = true;
isRoomOpened = true;
} else if (message.isRoomExists === true) {
document.querySelector('#btn-join-room').disabled = false;
isRoomOpened = true;
}
if (connection.isInitiator && message.checkIfRoomExists === true && message.roomid === connection.sessionid) {
connection.sendCustomMessage({
isRoomExists: true,
roomid: 'room-id'
});
}
};
connection.connect();
(function looper() {
if(connection.isInitiator) return;
connection.sendCustomMessage({
checkIfRoomExists: true,
roomid: 'room-id'
});
if (isRoomOpened === true) return;
setTimeout(looper, 3000); // check after every 3-seconds
})();
</script>
One more question. How do i rejoin the student if he come back again???
I am developing a video class app. Once the staff started the class means, i will send mail to all students who are all subscribed to that class. How do i disable the Join button in Student side if the Staff is not available, i mean if video class is not started. I'm using RTCMultiConnection V2.2.2