Skip to content

Commit

Permalink
Fixed muaz-khan#653 demos/keep-rejoining.html
Browse files Browse the repository at this point in the history
  • Loading branch information
muaz-khan committed Oct 17, 2018
1 parent 5453a45 commit 4e0094c
Showing 1 changed file with 11 additions and 3 deletions.
14 changes: 11 additions & 3 deletions demos/keep-rejoining.html
Original file line number Diff line number Diff line change
@@ -1,4 +1,4 @@
<!-- Demo version: 2018.08.24 -->
<!-- Demo version: 2018.10.17 -->

<!DOCTYPE html>
<html lang="en" dir="ltr">
Expand Down Expand Up @@ -69,7 +69,8 @@ <h1>
// ......................................................
document.getElementById('open-room').onclick = function() {
disableInputButtons();
connection.open(document.getElementById('room-id').value, function() {
connection.userid = document.getElementById('room-id').value;
connection.open(connection.userid, function() {
showRoomURL(connection.sessionid);
});
};
Expand Down Expand Up @@ -159,6 +160,10 @@ <h1>
connection.connectWithAllParticipants();
}, 3000);
}

if(event.type === 'remote' && !connection.isInitiator) {
document.querySelector('h1').innerHTML = 'Joined a room';
}
};

connection.onstreamended = function(event) {
Expand Down Expand Up @@ -261,14 +266,17 @@ <h1>
</script>

<script type="text/javascript">

// via: https://github.com/muaz-khan/RTCMultiConnection/wiki/checkPresence-and-automatically-join-rejoin-rooms
connection.autoCloseEntireSession = true;

var isOwnerPesenceCheckingOn = false;
var connectWithAllParticipantsOnce = false;

connection.onleave = function(event) {
if (event.userid === connection.sessionid && !isOwnerPesenceCheckingOn) {
console.info('Room is closed. Rechecking for room presence.');
document.querySelector('h1').innerHTML = 'Room is closed. Rechecking for room presence.';

isOwnerPesenceCheckingOn = true;
connectWithAllParticipantsOnce = true;

Expand Down

0 comments on commit 4e0094c

Please sign in to comment.