简体   繁体   中英

How to add event listener to call hangup PHP AGI?

I am working on a project that records how long a caller is on the line.

My question is, how do you add an event listener for hangup with AMI or AGI?

Currently, I am trying to use AGI's Manager class however the event is not firing when the call is terminated.

$Log_File = "/var/www/html/admin/modules/timetracker/agi-bin/Log.txt";

function CallHungUp($e,$ch=NULL,$u=NULL,$ca=NULL)
{
    file_put_contents( $Log_File,"HANGUP E - " . implode(' ',$e),FILE_APPEND);
}

$asm = new AGI_AsteriskManager();
if($asm->connect("localhost","Secret","Info"))
{
    $asm->add_event_handler('Hangup','CallHungUp');
}
else
{
    file_put_contents( $Log_File,"UNABLE TO CONNECT TO ASM",FILE_APPEND);
}

There are 3 possible way

1) use h-extension

2) check SIGKILL event

3) check CHANNEL(status) after long action.

The technical post webpages of this site follow the CC BY-SA 4.0 protocol. If you need to reprint, please indicate the site URL or the original address.Any question please contact:yoyou2525@163.com.

 
粤ICP备18138465号  © 2020-2024 STACKOOM.COM