zmarius81 / asterisk.io

node.js asterisk pbx io
41 stars 25 forks source link

agiHandler.command problem #3

Open twosouth opened 9 years ago

twosouth commented 9 years ago

Hi I am trying to execute the following code which should transfer the call to the target extension.

agiHandler.command('Set Extension 1000', function (code, result, data) { });

The java equivelant of this code works fine so I'm not sure if I have a syntax error. Here is what I have in the onsole:

Console verbose was 12 and is now 25. == Using SIP RTP CoS mark 5 -- Executing [1300@default:1] AGI("SIP/2000-0000004b", "agi://10.0.1.106/hello.agi") in new stack

0x7f7ad001c280 -- Probation passed - setting RTP source address to 10.0.1.103:4022 -- <SIP/2000-0000004b> Playing 'digits/8.gsm' (language 'en') 0x7f7ad001c280 -- Probation passed - setting RTP source address to 10.0.1.103:4022 -- <SIP/2000-0000004b> Playing 'digits/20.gsm' (language 'en') -- <SIP/2000-0000004b> Playing 'digits/7.gsm' (language 'en') -- <SIP/2000-0000004b> Playing 'digits/a-m.gsm' (language 'en') -- <SIP/2000-0000004b>AGI Script agi://10.0.1.106/hello.agi completed, returning 4 == Spawn extension (default, 1000, 1) exited non-zero on 'SIP/2000-0000004b'

Am I just missing something?

twosouth commented 9 years ago

I forgot to include the entire method:

    agiHandler.command('Set Extension 1000', function (code, result, data) {

        console.log("Set Extension")
        console.log('///////////////////////// - code');
        console.log(JSON.stringify(code));
        console.log('///////////////////////// - result');
        console.log(JSON.stringify(result));
        console.log('///////////////////////// - data');
        console.log(JSON.stringify(data));

    });

    agiHandler.command('Say Time "1414330073" ""', function(){

        agiHandler.command('HangUp', function(){
            // hangup the channel, this will raise hangup and close event
        });

    });
zmarius81 commented 8 years ago

Sorry for the late response. Your code should be

agiHandler.command('Set Extension 1000', function (code, result, data) {

        console.log("Set Extension")
        console.log('///////////////////////// - code');
        console.log(JSON.stringify(code));
        console.log('///////////////////////// - result');
        console.log(JSON.stringify(result));
        console.log('///////////////////////// - data');
        console.log(JSON.stringify(data));

        // now you have the 'Set Extension 1000' command finished

       // do other commands like this one
        agiHandler.command('Say Time "1414330073" ""', function(){

              // here you get the point, hangup after 'Say Time'
              agiHandler.command('HangUp', function(){
                     // hangup the channel, this will raise hangup and close event
              });

        });

    });