Handle terminate call in JS client

master
Daniel Berteaud 11 years ago
parent 1694d22534
commit 9c2808c046
  1. 40
      public/js/vroom.js

@ -1019,6 +1019,14 @@ function initVroom(room) {
}, 2000); }, 2000);
} }
}); });
// An owner is terminating the call, obey and leave the room now
webrtc.on('terminate_room', function(data){
if (peers[data.id].role != 'owner' || data.roomType == 'screen'){
return;
}
hangupCall;
window.location.assign(rootUrl + 'goodbye/' + roomName);
});
// Handle volume changes from our own mic // Handle volume changes from our own mic
webrtc.on('volumeChange', function (volume, treshold){ webrtc.on('volumeChange', function (volume, treshold){
@ -1947,12 +1955,12 @@ function initVroom(room) {
}); });
$('#confirmQuitButton').click(function() { $('#confirmQuitButton').click(function() {
hangupCall; hangupCall;
window.location.assign(rootUrl + 'goodby/' + roomName); window.location.assign(rootUrl + 'goodbye/' + roomName);
}); });
$('#confirmWipeAndQuitButton').click(function(){ $('#confirmWipeAndQuitButton').click(function(){
wipeRoomData(); wipeRoomData();
hangupCall; hangupCall;
window.location.assign(rootUrl + 'goodby/' + roomName); window.location.assign(rootUrl + 'goodbye/' + roomName);
}); });
window.onunload = window.onbeforeunload = hangupCall; window.onunload = window.onbeforeunload = hangupCall;
@ -2044,6 +2052,34 @@ function initVroom(room) {
wipeRoomData(); wipeRoomData();
}); });
// Display terminate room modal
$('#terminateRoomButton').click(function(){
$('#terminateModal').modal('show');
});
// Really terminate the room now
$('#confirmTerminateButton').click(function(){
// Ask all the peers to quit now
webrtc.sendToAll('terminate_room', {});
wipeRoomData();
$.ajax({
data: {
action: 'deleteRoom',
room: roomName
},
async: false,
error: function(data) {
$.notify(locale.ERROR_OCCURRED, 'error');
},
success: function(data) {
if (data.status == 'success' && data.msg && data.msg != ''){
$.notify(data.msg, 'info');
}
}
});
hangupCall;
window.location.assign(rootUrl + 'goodbye/' + roomName);
});
if (etherpad.enabled){ if (etherpad.enabled){
$('#etherpadButton').change(function(){ $('#etherpadButton').change(function(){
var action = ($(this).is(':checked')) ? 'show':'hide'; var action = ($(this).is(':checked')) ? 'show':'hide';

Loading…
Cancel
Save