0

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 ?

user723826
  • 83
  • 1
  • 6

1 Answers1

0

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");
}
pce
  • 5,571
  • 2
  • 20
  • 25
  • 1. Return value from stream_file/get_data will not work. Because it will not capture disconnect if there is third party call (CURL) and user disconnects the call at that time. 2. Shutdown function gets invoked onl after exit is called or script finished. 3. SIGHUP is not working, function is NOT getting called on call termination. – user723826 Feb 27 '13 at 11:09
  • Working, need to add statement, declare(ticks = 1); – user723826 Feb 27 '13 at 12:53