Hi Guys, I'm using an outbound socket to control calls, and it works a charm. However, what I'd like to do is send a custom event regarding the call on hang-up. The way I see things happening at the moment, and I could be wrong, is that the socket is closed when a hang-up occurs, so am I taking a chance trying to send the event then? (try to sneak out the event before socket closure happens) The other option is of course to open an inbound socket and send the event, but I'd rather not do that if possible. Regards
On Sun, Aug 2, 2009 at 12:38 PM, Nik Middleton < nik.middleton@noblesolutions.co.uk> wrote:
Hi Guys,
I’m using an outbound socket to control calls, and it works a charm. However, what I’d like to do is send a custom event regarding the call on hang-up. The way I see things happening at the moment, and I could be wrong, is that the socket is closed when a hang-up occurs, so am I taking a chance trying to send the event then? (try to sneak out the event before socket closure happens) The other option is of course to open an inbound socket and send the event, but I’d rather not do that if possible.
Nik, Perhaps the "linger" event socket command will do what you need? Check out this commit: http://lists.freeswitch.org/pipermail/freeswitch-svn/2009-January/009391.htm... Let me know if it works for you and I'll be sure to get it documented properly. If you get it working I'd love to see a code snippet so we can wikify this knowledge. :) Thanks, MC
Hi, does anyone have an example of a simple PHP socket script that will listen and spawn of a process that handles the incoming call? I understand the inbound socket and code such as this http://wiki.freeswitch.org/wiki/PHP_Event_Socket that will let me initiate operations. It's the constantly running php socket program that I can't get my head around, and how it will spawn another php script that will be able to do things like answer the session, get dtmf, etc. -- Greg On Aug 2, 2009, at 6:35 PM, Michael Collins wrote:
On Sun, Aug 2, 2009 at 12:38 PM, Nik Middleton <nik.middleton@noblesolutions.co.uk
wrote: Hi Guys,
I’m using an outbound socket to control calls, and it works a charm. However, what I’d like to do is send a custom event regarding the call on hang-up. The way I see things happening at the moment, and I could be wrong, is that the socket is closed when a hang-up occurs, so am I taking a chance trying to send the event then? (try to sneak out the event before socket closure happens) The other option is of course to open an inbound socket and send the event, but I’d rather not do that if possible.
Nik,
Perhaps the "linger" event socket command will do what you need? Check out this commit: http://lists.freeswitch.org/pipermail/freeswitch-svn/2009-January/009391.htm...
Let me know if it works for you and I'll be sure to get it documented properly. If you get it working I'd love to see a code snippet so we can wikify this knowledge. :)
Thanks, MC _______________________________________________ FreeSWITCH-users mailing list FreeSWITCH-users@lists.freeswitch.org http://lists.freeswitch.org/mailman/listinfo/freeswitch-users UNSUBSCRIBE:http://lists.freeswitch.org/mailman/options/freeswitch-users http://www.freeswitch.org
I wrote some notes on this but have yet to wiki it. example of an outbound socket connection where the call is answered, a variable is set then perhaps play one of the pre-installed files and hangup. ivrd fs_ivrd comes with freeswitch. It being a small daemon just invokes the script defined in a variable and passes data from it via STDIN/OUT Since this is an outbound socket connections it needs to be defined in the dialplan. Ex: <extension name="outbound-socket"> <condition field="destination_number" expression="^55(522)$"> <action application="set" data="ivr_path=/usr/local/freeswitch/scripts/ivrd-demo.php"/> <action application="socket" data="127.0.0.1:8084 async full"/> </condition> </extension> The above dialplan sample would invoke ivr-demo.php when 55522 is called as long as fs_ivrd is running. To start fs_ivrd: /usr/local/freeswitch/bin/fs_ivrd -h 127.0.0.1 -p 8004 It takes 2 arguments -h for hostname and -p for port. PHP Code #!/usr/bin/php -q <?php // set a couple of things so we dont kill the system ob_implicit_flush(true); set_time_limit(30); // Open stdin so we can read the AGI data in $in = fopen("php://stdin", "r"); // Connect echo "connect\n\n"; // Answer echo "sendmsg\n"; echo "call-command: execute\n"; echo "execute-app-name: answer\n\n"; // Play a prompt echo "sendmsg\n"; echo "call-command: execute\n"; echo "execute-app-name: playback\n"; echo "execute-app-arg: /usr/local/freeswitch/sounds/en/us/callie/ivr/8000/ivr-welcome_to_freeswitch.wav\n\n"; // Wait sleep(5); // Hangup echo "sendmsg\n"; echo "call-command: hangup\n\n"; fclose($in); ?> ivrd will call this script for each call. All itdoes is answer the channel tell FreeSWITCH to play the “welcome to freeswitch” prompt. Since the script is now controlling all call flow I needed to add a wait or it would send the hangup immediately before the prompt was played. Some improvements possible but that's 1 way to do it. It would be possible to do the socket directly in PHP but fs_ivrd is a nice option too. -- W
Thanks so much, William. This gives me a great start. -- Greg On Aug 4, 2009, at 7:04 PM, William Suffill wrote:
I wrote some notes on this but have yet to wiki it.
example of an outbound socket connection where the call is answered, a variable is set then perhaps play one of the pre-installed files and hangup. ivrd
fs_ivrd comes with freeswitch. It being a small daemon just invokes the script defined in a variable and passes data from it via STDIN/OUT
Since this is an outbound socket connections it needs to be defined in the dialplan.
Ex:
<extension name="outbound-socket">
<condition field="destination_number" expression="^55(522)$">
<action application="set" data="ivr_path=/usr/local/freeswitch/scripts/ivrd-demo.php"/>
<action application="socket" data="127.0.0.1:8084 async full"/>
</condition>
</extension>
The above dialplan sample would invoke ivr-demo.php when 55522 is called as long as fs_ivrd is running. To start fs_ivrd:
/usr/local/freeswitch/bin/fs_ivrd -h 127.0.0.1 -p 8004
It takes 2 arguments -h for hostname and -p for port.
PHP Code
#!/usr/bin/php -q
<?php
// set a couple of things so we dont kill the system
ob_implicit_flush(true);
set_time_limit(30);
// Open stdin so we can read the AGI data in
$in = fopen("php://stdin", "r");
// Connect
echo "connect\n\n";
// Answer
echo "sendmsg\n";
echo "call-command: execute\n";
echo "execute-app-name: answer\n\n";
// Play a prompt
echo "sendmsg\n";
echo "call-command: execute\n";
echo "execute-app-name: playback\n";
echo "execute-app-arg: /usr/local/freeswitch/sounds/en/us/callie/ivr/8000/ivr- welcome_to_freeswitch.wav\n\n";
// Wait
sleep(5);
// Hangup
echo "sendmsg\n";
echo "call-command: hangup\n\n";
fclose($in);
?>
ivrd will call this script for each call. All itdoes is answer the channel tell FreeSWITCH to play the “welcome to freeswitch” prompt. Since the script is now controlling all call flow I needed to add a wait or it would send the hangup immediately before the prompt was played.
Some improvements possible but that's 1 way to do it. It would be possible to do the socket directly in PHP but fs_ivrd is a nice option too.
-- W
_______________________________________________ FreeSWITCH-users mailing list FreeSWITCH-users@lists.freeswitch.org http://lists.freeswitch.org/mailman/listinfo/freeswitch-users UNSUBSCRIBE:http://lists.freeswitch.org/mailman/options/freeswitch-users http://www.freeswitch.org
there is some other info on http://wiki.freeswitch.org/wiki/Perl_esl about this as well. could somone try to put together some decent docs on fs_ivrd on the wiki as I keep getting asked this stuff privately as well. Mike On Aug 4, 2009, at 7:04 PM, William Suffill wrote:
I wrote some notes on this but have yet to wiki it.
example of an outbound socket connection where the call is answered, a variable is set then perhaps play one of the pre-installed files and hangup. ivrd
fs_ivrd comes with freeswitch. It being a small daemon just invokes the script defined in a variable and passes data from it via STDIN/OUT
Since this is an outbound socket connections it needs to be defined in the dialplan.
Ex:
<extension name="outbound-socket">
<condition field="destination_number" expression="^55(522)$">
<action application="set" data="ivr_path=/usr/local/freeswitch/scripts/ivrd-demo.php"/>
<action application="socket" data="127.0.0.1:8084 async full"/>
</condition>
</extension>
The above dialplan sample would invoke ivr-demo.php when 55522 is called as long as fs_ivrd is running. To start fs_ivrd:
/usr/local/freeswitch/bin/fs_ivrd -h 127.0.0.1 -p 8004
It takes 2 arguments -h for hostname and -p for port.
PHP Code
#!/usr/bin/php -q
<?php
// set a couple of things so we dont kill the system
ob_implicit_flush(true);
set_time_limit(30);
// Open stdin so we can read the AGI data in
$in = fopen("php://stdin", "r");
// Connect
echo "connect\n\n";
// Answer
echo "sendmsg\n";
echo "call-command: execute\n";
echo "execute-app-name: answer\n\n";
// Play a prompt
echo "sendmsg\n";
echo "call-command: execute\n";
echo "execute-app-name: playback\n";
echo "execute-app-arg: /usr/local/freeswitch/sounds/en/us/callie/ivr/8000/ivr- welcome_to_freeswitch.wav\n\n";
// Wait
sleep(5);
// Hangup
echo "sendmsg\n";
echo "call-command: hangup\n\n";
fclose($in);
?>
ivrd will call this script for each call. All itdoes is answer the channel tell FreeSWITCH to play the “welcome to freeswitch” prompt. Since the script is now controlling all call flow I needed to add a wait or it would send the hangup immediately before the prompt was played.
Some improvements possible but that's 1 way to do it. It would be possible to do the socket directly in PHP but fs_ivrd is a nice option too.
-- W
_______________________________________________ FreeSWITCH-users mailing list FreeSWITCH-users@lists.freeswitch.org http://lists.freeswitch.org/mailman/listinfo/freeswitch-users UNSUBSCRIBE:http://lists.freeswitch.org/mailman/options/freeswitch-users http://www.freeswitch.org
I'll see what I can do. Got a few sections of the PHP ESL to finish but should be able to write up fs_ivrd as well. -- W
participants (5)
-
Greg Thoen
-
Michael Collins
-
Michael Jerris
-
Nik Middleton
-
William Suffill