Asterisk AGI hangup setcallback - making it work

chris (2007-05-05 18:21:49)
4080 views
1 replies
The $AGI->setcallback() method doesn't work on Asterisk 1.4.4. I have just tried this on Asterisk 1.4.4, but it seems to be yet anothing thing which is broken in the the newset builds. The callback should trap the Asterisk Tx on hangup and allow the AGI script to clean up gracefully.

So just to illustrate, the usual mechanism to get this working would look like this:
use Asterisk::AGI;
my $agi = new Asterisk::AGI;
$agi->setcallback(&hangup);
my %input = $agi->ReadParse();

sub hangcallback{
        # do something in here
        exit 0;
}

Since this appears to have stopped working, the only other way to achieve this is by writing a custom signal handler so that your perl script traps the HUP signal and does something useful before dying. This would be done in this way:
use Asterisk::AGI;
my $agi = new Asterisk::AGI;
$SIG{HUP} = sub {
        # do something useful
        exit(0);
};
my %input = $agi->ReadParse();

Using this mechanism, you can mimic the functionality provided by the AGI setcallback method in your agi scripts.

I hope this saves somebody some hours, because I just wasted an eon trying to debug this crap.

christo
comment
Ken Arakelian
2009-08-21 18:47:07

thank you

Thank you for troubleshooting this!!

The $AGI->setcallback() method doesn't work on Asterisk 1.4.4. I have just tried this on Asterisk 1.4.4, but it seems to be yet anothing thing which is broken in the the newset builds. The callback should trap the Asterisk Tx on hangup and allow the AGI script to clean up gracefully.

So just to illustrate, the usual mechanism to get this working would look like this:
use Asterisk::AGI;
my $agi = new Asterisk::AGI;
$agi->setcallback(&hangup);
my %input = $agi->ReadParse();

sub hangcallback{
        # do something in here
        exit 0;
}

Since this appears to have stopped working, the only other way to achieve this is by writing a custom signal handler so that your perl script traps the HUP signal and does something useful before dying. This would be done in this way:
use Asterisk::AGI;
my $agi = new Asterisk::AGI;
$SIG{HUP} = sub {
        # do something useful
        exit(0);
};
my %input = $agi->ReadParse();

Using this mechanism, you can mimic the functionality provided by the AGI setcallback method in your agi scripts.

I hope this saves somebody some hours, because I just wasted an eon trying to debug this crap.

christo
reply iconedit reply