diff --git a/assets/js/components/calls/callWindow.js b/assets/js/components/calls/callWindow.js index 6405c247..de7a926f 100644 --- a/assets/js/components/calls/callWindow.js +++ b/assets/js/components/calls/callWindow.js @@ -319,19 +319,19 @@ ComunicWeb.components.calls.callWindow = { return; //Check if all other members rejected call - var allRejected = true; + var allDisconnected = true; call.info.members.forEach(function(member){ - if(member.status != "rejected" && member.userID != userID()) - allRejected = false; + if(member.status != "rejected" && member.status != "hang_up" && member.userID != userID()) + allDisconnected = false; }); //Check if all call peer rejected the call - if(allRejected){ - call.setLoadingMessage("All other peers rejected the call !"); + if(allDisconnected){ + call.setLoadingMessage("Conversation terminated."); setTimeout(function(){ call.close(); - }, 20000); + }, 5000); return; } @@ -542,5 +542,8 @@ ComunicWeb.components.calls.callWindow = { element.removePeerConnection(); } } + + //Notify server + ComunicWeb.components.calls.interface.hangUp(call.info.id, function(){}); } } \ No newline at end of file diff --git a/assets/js/components/calls/interface.js b/assets/js/components/calls/interface.js index 20f6d9a4..80e81278 100644 --- a/assets/js/components/calls/interface.js +++ b/assets/js/components/calls/interface.js @@ -82,5 +82,22 @@ ComunicWeb.components.calls.interface = { true, callback ); + }, + + /** + * Hang up a call + * + * @param {Number} call_id The ID of the target call + * @param {function} callback Function to call on call callback + */ + hangUp: function(call_id, callback){ + ComunicWeb.common.api.makeAPIrequest( + "calls/hangUp", + { + call_id: call_id, + }, + true, + callback + ); } } \ No newline at end of file