Call disconnect for asterisk

自闭症网瘾萝莉.ら 提交于 2020-01-07 05:04:19

问题


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

易学教程内所有资源均来自网络或用户发布的内容,如有违反法律规定的内容欢迎反馈
该文章没有解决你所遇到的问题?点击提问,说说你的问题,让更多的人一起探讨吧!