I think you might be twisted around its possible that doing what you are doing is much more complicated than just using the socket app. If you are just trying to play a file and get a digits etc you could do it all with existing dialplan apps. On Fri, Apr 6, 2012 at 12:31 PM, Alex Crow <acrow@integrafin.co.uk> wrote:
On 01/04/12 17:29, Alex Crow wrote:
On 01/04/12 11:26, Peter Olsson wrote:
In your sample you're actually queuing "sleep(1000)" to the channel. So first it will queue play_and_get_digits, inside that loop it will find more commands in the queue, and exeute them, so in the end it will only execute a bunch of "sleep(1000)".
You're better of using a sleep in your module directly (not tell FS to sleep). Also you will need to poll the events in the loop somehow., checkout the perl sample here: http://wiki.freeswitch.org/wiki/Esl#Simple_Perl_Example
Peter,
I've changed to the below (adapted that Perl example) and I only hear the prompt for digits when the webserver times out after 60 seconds. Any time I make any call to ESL after the execute, I don't hear the prompt in a timely fashion. This is so complicated as I'm not really that good at software development, I'm more a systems/networks guy. I feel like a total thickie here, but the docs don't seem to explain in which order I should call things and expect to get replies, etc.
$esl = new ESLconnection('localhost','8021','ClueCon');
$event = $esl->events('plain', 'ALL'); //$event = $esl->filter("Unique-ID",$uuid);
sleep (1);
$res = $esl->execute("play_and_get_digits","4 11 1 5000 # ivr/ivr-please_enter_the_phone_number.wav ivr/ivr-that_was_an_invalid_entry.wav target_num \d+", "$uuid");
$job_uuid = $res->getHeader("Job-UUID"); $status = $res->getHeader("Reply-Text");
//$foo = $uuid . ' target_num';
echo $status;
$stay_connected = 1; while ( $stay_connected ) { $e = $esl->recvEventTimed(0); if ( $e ) { $ev_name = $e->getHeader("Event-Name"); # Should we check for the $job_uuid to match the background job ? //if ( $ev_name == 'BACKGROUND_JOB' ) { // if ( $e->getHeader("Job-UUID") == $uuid ) { // $call_result = $e->getBody(); // echo "Result of call to $target was $call_result\n\n"; // } //} else echo $ev_name; if ( $ev_name == 'EXECUTE_COMPLETE' ) { //my $digit = $e->getHeader("DTMF-Digit"); // print "Received DTMF digit: $digit\n"; //if ( $digit =~ m/\D/ ) {a // print "Exiting...\n"; //if ( $e->getHeader("Job-UUID") == $job_uuid ) { $stay_connected = 0; //} //} } else { # Some other event } } else { # do other things while waiting for events //sleep (1); } }
$event=$esl->sendRecv("api uuid_getvar $uuid target_num");
$ret = $event->getBody();
$esl->disconnect();
Apologies for my newbishness and many thanks for your help so far.
Hoping for an epiphany when I sudddenly understand what I am doing!
Alex
Can anyone help with this? I updated to latest Git, thinking it may have been a bug, and still have the same problem, when I try to wait for events as in the above code, it stops the playback of the "enter the phone number" from happening until after the web server times out.
Logically I can't see a reason for this, is it because you can't use an inbound connection activated by calling from curl in the dialplan? If this is indeed the case I could try rewriting this for outbound but I feel that will be more complex for a relative beginner programmer.
If I have missed some vital or obvious concept feel free to chastise me :-).
Thanks
Alex
_________________________________________________________________________ Professional FreeSWITCH Consulting Services: consulting@freeswitch.org http://www.freeswitchsolutions.com
FreeSWITCH-powered IP PBX: The CudaTel Communication Server http://www.cudatel.com
Official FreeSWITCH Sites http://www.freeswitch.org http://wiki.freeswitch.org http://www.cluecon.com
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
-- Anthony Minessale II FreeSWITCH http://www.freeswitch.org/ ClueCon http://www.cluecon.com/ Twitter: http://twitter.com/FreeSWITCH_wire AIM: anthm MSN:anthony_minessale@hotmail.com GTALK/JABBER/PAYPAL:anthony.minessale@gmail.com IRC: irc.freenode.net #freeswitch FreeSWITCH Developer Conference sip:888@conference.freeswitch.org googletalk:conf+888@conference.freeswitch.org pstn:+19193869900