问题
How to capture call disconnect for asterisk using PHPAGI ? For e.g. if user disconnects the call which event is invoked ? How to capture it ?
回答1:
You can check the Return Results of your PHP-AGI API calls,
for example stream_file returns -1
on hangup.
You could also invoke another AGI Script on the h
Extension in the Dialplan.
If you have to clean up something, you could also register a Shutdown function.
Another Approach is to register a Signal Handler which edmund long described in his blog. PCNTL is a PHP extension, to enable PCNTL recompile PHP with --enable-pcntl
.
<?php
declare(ticks=1);
function sig_handler($signo)
{ //Do some stuff in here
exit(0);
}
//Register the hangup handler
if (function_exists('pcntl_signal'))
{
pcntl_signal(SIGHUP, "sig_handler");
}
来源:https://stackoverflow.com/questions/14980183/call-disconnect-for-asterisk