From 9c2808c0460d085a9e35ea0e262814642f931011 Mon Sep 17 00:00:00 2001 From: Daniel Berteaud Date: Wed, 18 Jun 2014 12:50:18 +0200 Subject: [PATCH] Handle terminate call in JS client --- public/js/vroom.js | 40 ++++++++++++++++++++++++++++++++++++++-- 1 file changed, 38 insertions(+), 2 deletions(-) diff --git a/public/js/vroom.js b/public/js/vroom.js index a2a3317..a91f284 100644 --- a/public/js/vroom.js +++ b/public/js/vroom.js @@ -1019,6 +1019,14 @@ function initVroom(room) { }, 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 webrtc.on('volumeChange', function (volume, treshold){ @@ -1947,12 +1955,12 @@ function initVroom(room) { }); $('#confirmQuitButton').click(function() { hangupCall; - window.location.assign(rootUrl + 'goodby/' + roomName); + window.location.assign(rootUrl + 'goodbye/' + roomName); }); $('#confirmWipeAndQuitButton').click(function(){ wipeRoomData(); hangupCall; - window.location.assign(rootUrl + 'goodby/' + roomName); + window.location.assign(rootUrl + 'goodbye/' + roomName); }); window.onunload = window.onbeforeunload = hangupCall; @@ -2044,6 +2052,34 @@ function initVroom(room) { 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){ $('#etherpadButton').change(function(){ var action = ($(this).is(':checked')) ? 'show':'hide';