forked from Mirrors/freeswitch
FS-9979: [verto.js] When verto client rejects a call returns hangup cause NORMAL_CLEARING #comment passing neither cause or causeCode will result in normal clearing, passing either one of cause or causeCode will result in that value being passed and parsed on the server side, if the cause is valid it will be accepted otherwise it will try to validate causeCode instead, if neither are true it defaults to normal clearing #resolve
This commit is contained in:
parent
197bbd8cab
commit
89e3a7bb4a
270
html5/verto/demo/js/verto-min.js
vendored
270
html5/verto/demo/js/verto-min.js
vendored
File diff suppressed because one or more lines are too long
@ -228,7 +228,7 @@ var callbacks = {
|
||||
});
|
||||
|
||||
$("#declinebtn").click(function() {
|
||||
cur_call.hangup();
|
||||
cur_call.hangup({"cause": "CALL_REJECTED"});
|
||||
$('#dialog-incoming-call').dialog('close');
|
||||
});
|
||||
|
||||
|
@ -2194,14 +2194,6 @@
|
||||
dialog.lastState = dialog.state;
|
||||
dialog.state = state;
|
||||
|
||||
if (!dialog.causeCode) {
|
||||
dialog.causeCode = 16;
|
||||
}
|
||||
|
||||
if (!dialog.cause) {
|
||||
dialog.cause = "NORMAL CLEARING";
|
||||
}
|
||||
|
||||
if (dialog.callbacks.onDialogState) {
|
||||
dialog.callbacks.onDialogState(this);
|
||||
}
|
||||
@ -2321,6 +2313,10 @@
|
||||
}
|
||||
}
|
||||
|
||||
if (!dialog.cause && !dialog.causeCode) {
|
||||
dialog.cause = "NORMAL_CLEARING";
|
||||
}
|
||||
|
||||
if (dialog.state.val >= $.verto.enum.state.new.val && dialog.state.val < $.verto.enum.state.hangup.val) {
|
||||
dialog.setState($.verto.enum.state.hangup);
|
||||
} else if (dialog.state.val < $.verto.enum.state.destroy) {
|
||||
|
@ -267,9 +267,7 @@ if(callback){callback(false,null,arg);}
|
||||
console.error(errorMessage);});}else{console.warn("Dialog: "+dialog.callID+' Browser does not support output device selection.');if(callback){callback(false,null,arg);}}}
|
||||
$.verto.dialog.prototype.setState=function(state){var dialog=this;if(dialog.state==$.verto.enum.state.ringing){dialog.stopRinging();}
|
||||
if(dialog.state==state||!checkStateChange(dialog.state,state)){console.error("Dialog "+dialog.callID+": INVALID state change from "+dialog.state.name+" to "+state.name);dialog.hangup();return false;}
|
||||
console.log("Dialog "+dialog.callID+": state change from "+dialog.state.name+" to "+state.name);dialog.lastState=dialog.state;dialog.state=state;if(!dialog.causeCode){dialog.causeCode=16;}
|
||||
if(!dialog.cause){dialog.cause="NORMAL CLEARING";}
|
||||
if(dialog.callbacks.onDialogState){dialog.callbacks.onDialogState(this);}
|
||||
console.log("Dialog "+dialog.callID+": state change from "+dialog.state.name+" to "+state.name);dialog.lastState=dialog.state;dialog.state=state;if(dialog.callbacks.onDialogState){dialog.callbacks.onDialogState(this);}
|
||||
switch(dialog.state){case $.verto.enum.state.early:case $.verto.enum.state.active:var speaker=dialog.useSpeak;console.info("Using Speaker: ",speaker);if(speaker&&speaker!=="any"&&speaker!=="none"){setTimeout(function(){dialog.setAudioPlaybackDevice(speaker);},500);}
|
||||
break;case $.verto.enum.state.trying:setTimeout(function(){if(dialog.state==$.verto.enum.state.trying){dialog.setState($.verto.enum.state.hangup);}},30000);break;case $.verto.enum.state.purge:dialog.setState($.verto.enum.state.destroy);break;case $.verto.enum.state.hangup:if(dialog.lastState.val>$.verto.enum.state.requesting.val&&dialog.lastState.val<$.verto.enum.state.hangup.val){dialog.sendMethod("verto.bye",{});}
|
||||
dialog.setState($.verto.enum.state.destroy);break;case $.verto.enum.state.destroy:if(typeof(dialog.verto.options.tag)==="function"){$('#'+dialog.params.tag).remove();}
|
||||
@ -281,6 +279,7 @@ break;case"verto.bye":dialog.hangup();break;case"verto.modify":if(e.holdState){i
|
||||
if(success){}
|
||||
break;default:break;}};$.verto.dialog.prototype.hangup=function(params){var dialog=this;if(params){if(params.causeCode){dialog.causeCode=params.causeCode;}
|
||||
if(params.cause){dialog.cause=params.cause;}}
|
||||
if(!dialog.cause&&!dialog.causeCode){dialog.cause="NORMAL_CLEARING";}
|
||||
if(dialog.state.val>=$.verto.enum.state.new.val&&dialog.state.val<$.verto.enum.state.hangup.val){dialog.setState($.verto.enum.state.hangup);}else if(dialog.state.val<$.verto.enum.state.destroy){dialog.setState($.verto.enum.state.destroy);}};$.verto.dialog.prototype.stopRinging=function(){var dialog=this;if(dialog.verto.ringer){dialog.verto.ringer.stop();}};$.verto.dialog.prototype.indicateRing=function(){var dialog=this;if(dialog.verto.ringer){dialog.verto.ringer.attr("src",dialog.verto.options.ringFile)[0].play();setTimeout(function(){dialog.stopRinging();if(dialog.state==$.verto.enum.state.ringing){dialog.indicateRing();}},dialog.verto.options.ringSleep);}};$.verto.dialog.prototype.ring=function(){var dialog=this;dialog.setState($.verto.enum.state.ringing);dialog.indicateRing();};$.verto.dialog.prototype.useVideo=function(on){var dialog=this;dialog.params.useVideo=on;if(on){dialog.videoStream=dialog.audioStream;}else{dialog.videoStream=null;}
|
||||
dialog.rtc.useVideo(dialog.videoStream,dialog.localVideo);};$.verto.dialog.prototype.setMute=function(what){var dialog=this;return dialog.rtc.setMute(what);};$.verto.dialog.prototype.getMute=function(){var dialog=this;return dialog.rtc.getMute();};$.verto.dialog.prototype.setVideoMute=function(what){var dialog=this;return dialog.rtc.setVideoMute(what);};$.verto.dialog.prototype.getVideoMute=function(){var dialog=this;return dialog.rtc.getVideoMute();};$.verto.dialog.prototype.useStereo=function(on){var dialog=this;dialog.params.useStereo=on;dialog.rtc.useStereo(on);};$.verto.dialog.prototype.dtmf=function(digits){var dialog=this;if(digits){dialog.sendMethod("verto.info",{dtmf:digits});}};$.verto.dialog.prototype.rtt=function(obj){var dialog=this;var pobj={};if(!obj){return false;}
|
||||
pobj.code=obj.code;pobj.chars=obj.chars;if(pobj.chars||pobj.code){dialog.sendMethod("verto.info",{txt:obj,noDialogParams:true});}};$.verto.dialog.prototype.transfer=function(dest,params){var dialog=this;if(dest){dialog.sendMethod("verto.modify",{action:"transfer",destination:dest,params:params});}};$.verto.dialog.prototype.hold=function(params){var dialog=this;dialog.sendMethod("verto.modify",{action:"hold",params:params});};$.verto.dialog.prototype.unhold=function(params){var dialog=this;dialog.sendMethod("verto.modify",{action:"unhold",params:params});};$.verto.dialog.prototype.toggleHold=function(params){var dialog=this;dialog.sendMethod("verto.modify",{action:"toggleHold",params:params});};$.verto.dialog.prototype.message=function(msg){var dialog=this;var err=0;msg.from=dialog.params.login;if(!msg.to){console.error("Missing To");err++;}
|
||||
|
@ -874,7 +874,7 @@ var callbacks = {
|
||||
});
|
||||
|
||||
$("#declinebtn").click(function() {
|
||||
cur_call.hangup();
|
||||
cur_call.hangup({"cause": "CALL_REJECTED"});
|
||||
$('#dialog-incoming-call').dialog('close');
|
||||
});
|
||||
|
||||
|
5
html5/verto/video_demo/js/verto-min.js
vendored
5
html5/verto/video_demo/js/verto-min.js
vendored
@ -267,9 +267,7 @@ if(callback){callback(false,null,arg);}
|
||||
console.error(errorMessage);});}else{console.warn("Dialog: "+dialog.callID+' Browser does not support output device selection.');if(callback){callback(false,null,arg);}}}
|
||||
$.verto.dialog.prototype.setState=function(state){var dialog=this;if(dialog.state==$.verto.enum.state.ringing){dialog.stopRinging();}
|
||||
if(dialog.state==state||!checkStateChange(dialog.state,state)){console.error("Dialog "+dialog.callID+": INVALID state change from "+dialog.state.name+" to "+state.name);dialog.hangup();return false;}
|
||||
console.log("Dialog "+dialog.callID+": state change from "+dialog.state.name+" to "+state.name);dialog.lastState=dialog.state;dialog.state=state;if(!dialog.causeCode){dialog.causeCode=16;}
|
||||
if(!dialog.cause){dialog.cause="NORMAL CLEARING";}
|
||||
if(dialog.callbacks.onDialogState){dialog.callbacks.onDialogState(this);}
|
||||
console.log("Dialog "+dialog.callID+": state change from "+dialog.state.name+" to "+state.name);dialog.lastState=dialog.state;dialog.state=state;if(dialog.callbacks.onDialogState){dialog.callbacks.onDialogState(this);}
|
||||
switch(dialog.state){case $.verto.enum.state.early:case $.verto.enum.state.active:var speaker=dialog.useSpeak;console.info("Using Speaker: ",speaker);if(speaker&&speaker!=="any"&&speaker!=="none"){setTimeout(function(){dialog.setAudioPlaybackDevice(speaker);},500);}
|
||||
break;case $.verto.enum.state.trying:setTimeout(function(){if(dialog.state==$.verto.enum.state.trying){dialog.setState($.verto.enum.state.hangup);}},30000);break;case $.verto.enum.state.purge:dialog.setState($.verto.enum.state.destroy);break;case $.verto.enum.state.hangup:if(dialog.lastState.val>$.verto.enum.state.requesting.val&&dialog.lastState.val<$.verto.enum.state.hangup.val){dialog.sendMethod("verto.bye",{});}
|
||||
dialog.setState($.verto.enum.state.destroy);break;case $.verto.enum.state.destroy:if(typeof(dialog.verto.options.tag)==="function"){$('#'+dialog.params.tag).remove();}
|
||||
@ -281,6 +279,7 @@ break;case"verto.bye":dialog.hangup();break;case"verto.modify":if(e.holdState){i
|
||||
if(success){}
|
||||
break;default:break;}};$.verto.dialog.prototype.hangup=function(params){var dialog=this;if(params){if(params.causeCode){dialog.causeCode=params.causeCode;}
|
||||
if(params.cause){dialog.cause=params.cause;}}
|
||||
if(!dialog.cause&&!dialog.causeCode){dialog.cause="NORMAL_CLEARING";}
|
||||
if(dialog.state.val>=$.verto.enum.state.new.val&&dialog.state.val<$.verto.enum.state.hangup.val){dialog.setState($.verto.enum.state.hangup);}else if(dialog.state.val<$.verto.enum.state.destroy){dialog.setState($.verto.enum.state.destroy);}};$.verto.dialog.prototype.stopRinging=function(){var dialog=this;if(dialog.verto.ringer){dialog.verto.ringer.stop();}};$.verto.dialog.prototype.indicateRing=function(){var dialog=this;if(dialog.verto.ringer){dialog.verto.ringer.attr("src",dialog.verto.options.ringFile)[0].play();setTimeout(function(){dialog.stopRinging();if(dialog.state==$.verto.enum.state.ringing){dialog.indicateRing();}},dialog.verto.options.ringSleep);}};$.verto.dialog.prototype.ring=function(){var dialog=this;dialog.setState($.verto.enum.state.ringing);dialog.indicateRing();};$.verto.dialog.prototype.useVideo=function(on){var dialog=this;dialog.params.useVideo=on;if(on){dialog.videoStream=dialog.audioStream;}else{dialog.videoStream=null;}
|
||||
dialog.rtc.useVideo(dialog.videoStream,dialog.localVideo);};$.verto.dialog.prototype.setMute=function(what){var dialog=this;return dialog.rtc.setMute(what);};$.verto.dialog.prototype.getMute=function(){var dialog=this;return dialog.rtc.getMute();};$.verto.dialog.prototype.setVideoMute=function(what){var dialog=this;return dialog.rtc.setVideoMute(what);};$.verto.dialog.prototype.getVideoMute=function(){var dialog=this;return dialog.rtc.getVideoMute();};$.verto.dialog.prototype.useStereo=function(on){var dialog=this;dialog.params.useStereo=on;dialog.rtc.useStereo(on);};$.verto.dialog.prototype.dtmf=function(digits){var dialog=this;if(digits){dialog.sendMethod("verto.info",{dtmf:digits});}};$.verto.dialog.prototype.rtt=function(obj){var dialog=this;var pobj={};if(!obj){return false;}
|
||||
pobj.code=obj.code;pobj.chars=obj.chars;if(pobj.chars||pobj.code){dialog.sendMethod("verto.info",{txt:obj,noDialogParams:true});}};$.verto.dialog.prototype.transfer=function(dest,params){var dialog=this;if(dest){dialog.sendMethod("verto.modify",{action:"transfer",destination:dest,params:params});}};$.verto.dialog.prototype.hold=function(params){var dialog=this;dialog.sendMethod("verto.modify",{action:"hold",params:params});};$.verto.dialog.prototype.unhold=function(params){var dialog=this;dialog.sendMethod("verto.modify",{action:"unhold",params:params});};$.verto.dialog.prototype.toggleHold=function(params){var dialog=this;dialog.sendMethod("verto.modify",{action:"toggleHold",params:params});};$.verto.dialog.prototype.message=function(msg){var dialog=this;var err=0;msg.from=dialog.params.login;if(!msg.to){console.error("Missing To");err++;}
|
||||
|
@ -565,7 +565,7 @@ var callbacks = {
|
||||
});
|
||||
|
||||
$("#declinebtn").click(function() {
|
||||
cur_call.hangup();
|
||||
cur_call.hangup({"cause": "CALL_REJECTED"});
|
||||
$('#dialog-incoming-call').dialog('close');
|
||||
});
|
||||
|
||||
|
@ -2766,11 +2766,11 @@ static switch_bool_t verto__answer_func(const char *method, cJSON *params, jsock
|
||||
|
||||
static switch_bool_t verto__bye_func(const char *method, cJSON *params, jsock_t *jsock, cJSON **response)
|
||||
{
|
||||
cJSON *obj = cJSON_CreateObject();
|
||||
cJSON *obj = cJSON_CreateObject(), *causeObj = NULL;
|
||||
switch_core_session_t *session;
|
||||
cJSON *dialog = NULL;
|
||||
const char *call_id = NULL, *cause_str = NULL;
|
||||
int err = 0;
|
||||
int err = 0, got_cause = 0;
|
||||
switch_call_cause_t cause = SWITCH_CAUSE_NORMAL_CLEARING;
|
||||
|
||||
*response = obj;
|
||||
@ -2795,6 +2795,24 @@ static switch_bool_t verto__bye_func(const char *method, cJSON *params, jsock_t
|
||||
|
||||
if (check != SWITCH_CAUSE_NONE) {
|
||||
cause = check;
|
||||
got_cause = 1;
|
||||
}
|
||||
}
|
||||
|
||||
if (!got_cause && (causeObj = cJSON_GetObjectItem(params, "causeCode"))) {
|
||||
int check = 0;
|
||||
const char *cause_str = NULL;
|
||||
|
||||
if (!zstr(causeObj->valuestring)) {
|
||||
check = atoi(causeObj->valuestring);
|
||||
} else if (causeObj->valueint) {
|
||||
check = causeObj->valueint;
|
||||
}
|
||||
|
||||
cause_str = switch_channel_cause2str((switch_call_cause_t)check);
|
||||
|
||||
if (!zstr(cause_str) && strcasecmp(cause_str, "unknown")) {
|
||||
cause = (switch_call_cause_t) check;
|
||||
}
|
||||
}
|
||||
|
||||
|
Loading…
Reference in New Issue
Block a user