[asterisk-users] Controlling calls

Steve Edwards asterisk.org at sedwards.com
Sat Jun 5 21:47:59 CDT 2010


On Sat, 5 Jun 2010, Adil Zaaraoui wrote:

> I want to write an AGI script doing this:
> 
> 1-user call a number.
> 2-asterisk call the agi script
> 3-the script dial the peer
> 4-if the call is answered, let the call up for 1min
> 5-then the script hangs up the channel.
> 
> I tried either in php or in java but no success.
> 
> In java i did this:
> 
> //////////////
> exec("Dial", "IAX2/400");
>  boolean t=true;
> while(t){
>      if(getChannel().getChannelStatus()==6)t=false;
>   }
> wait(60000);
> hangup();
> //////////
> in my extension.conf:
> exten =>777,1,AGI(agi://localhost/sc.agi)
> the script is running but it does not hangup.
> 
> Second solution,i tried this :
> exten => 777,1,Dial(IAX2/400,G(myscript))
> exten =>777,n(myscript),AGI(agi://localhost/sc.agi)
> 
> in sc.agi in this time i do not call exec("Dial","IAX2/400") statment; 
> but the audio stops, no ringing.
> 
> Do you have any solution.

0) Please post requests with a more meaningful subject. There are lots of 
ways to control calls.

1) Do you need to call an AGI? Can you use an absolute timeout of 1 
minute?

2) Is this your first AGI? While very simple, the AGI protocol is easy to 
violate.

3) You are executing "FastAGI." Is this required by the Java package you 
are using?

4) I'm just a 1.2 weenie and I've never used "G," but won't the "G" option 
transfer the calling party to "myscript" and the called party to 
"myscript+1?"

5) Not related to your issue, but "spinning" on the channel status doesn't 
look like a good idea. Adding a "wait(x)" to your while loop may help with 
CPU resource consumption.

6) More detail like what version of Asterisk and some console output with 
AGI debugging enabled may help.

-- 
Thanks in advance,
-------------------------------------------------------------------------
Steve Edwards       sedwards at sedwards.com      Voice: +1-760-468-3867 PST
Newline                                              Fax: +1-760-731-3000



More information about the asterisk-users mailing list