Automatically close ring screen if other peer gives up with connection

This commit is contained in:
Pierre HUBERT 2019-01-26 15:59:06 +01:00
parent 1a3117a603
commit 5a067001e9
2 changed files with 34 additions and 1 deletions

View File

@ -184,13 +184,36 @@ ComunicWeb.components.calls.controller = {
} }
//Show ring screen //Show ring screen
ComunicWeb.components.calls.ringScreen.show(name, 30, function(accept){ var prompting = true;
var ringScreenInfo = ComunicWeb.components.calls.ringScreen.show(name, 30, function(accept){
prompting = false;
undoIsProcessing(); undoIsProcessing();
ComunicWeb.components.calls.controller.applyReponseForCall(call, accept); ComunicWeb.components.calls.controller.applyReponseForCall(call, accept);
}); });
//Regulary check if the call is still valid
var interval = setInterval(function(){
if(!prompting)
return clearInterval(interval);
ComunicWeb.components.calls.interface.getInfo(call.id, function(info){
//Check for errors
if(info.error)
return;
//Refuse the call if everyone has left it
if(ComunicWeb.components.calls.utils.hasEveryoneLeft(info))
ringScreenInfo.respond(false);
});
}, 2000);
}); });
}); });

View File

@ -23,6 +23,7 @@ ComunicWeb.components.calls.ringScreen = {
* @param {number} timeout Timeout after which the call is automatically * @param {number} timeout Timeout after which the call is automatically
* considered as rejected * considered as rejected
* @param {(accept : boolean) => any} callback Callback function * @param {(accept : boolean) => any} callback Callback function
* @return {Object} Information about the window
*/ */
show: function(title, timeout, callback){ show: function(title, timeout, callback){
@ -98,6 +99,15 @@ ComunicWeb.components.calls.ringScreen = {
setTimeout(function(){ setTimeout(function(){
respond(false); respond(false);
}, timeout*1000); }, timeout*1000);
return {
/**
* A function to programmatically respond to call
*/
respond: respond
};
} }
} }