Answer the question
In order to leave comments, you need to log in
How to get channel variable in agi hangup event?
There is Asterisk, an AGI server on Node js and the asterisk-io library. Cannot get channel variable DIALSTATUS in body of hangup event. The library is synchronous, but the main file that interacts with it has been rewritten using Promise into asynchronous code.
Below is an asynchronous call to the Asterisk command:
agiHandler.asyncExec=function (_cmd,_params) {
return new Promise(function(resolve, reject) {
_cmd='exec "'+_cmd+'"'+(_params!=undefined?' "'+_params+'"':'');
agiHandler.doLog(L_INFO,'asyncExec() -> start -> '+_cmd);
agiHandler.command(_cmd,function(code,result,value) {
var res={code:code,result:result,value:value};
agiHandler.doLog(L_INFO,'asyncExec() -> end -> '+_cmd+' -> result -> '+JSON.stringify(res));
resolve(res);
});
});
};
agiHandler.on('hangup', function(){
new Promise(function(resolve, reject){
agiHandler.doLog(L_INFO,'hangup event');
console.log();
//============================================ get vars
//console.log("========================== handler command: ",_cmd)
agiHandler.asyncExec('get variable', 'DIALSTATUS').then(function(res){
console.log("========================== getting var in ast-io hangup event: ", res);
resolve(res);
})
//============================================ end get
});
Answer the question
In order to leave comments, you need to log in
Didn't find what you were looking for?
Ask your questionAsk a Question
731 491 924 answers to any question