[Freeswitch-users] Dialplan/PHP esl variable problem.

Peter Olsson peter.olsson at visionutveckling.se
Sun Apr 1 13:33:27 MSD 2012


I believe that it's only sync in outbound mode. Maybe it would be easier to do what you want in outbound mode instead?

/Peter

________________________________
Från: freeswitch-users-bounces at lists.freeswitch.org [freeswitch-users-bounces at lists.freeswitch.org] för Alex Crow [acrow at integrafin.co.uk]
Skickat: den 1 april 2012 10:40
Till: freeswitch-users at lists.freeswitch.org
Ämne: Re: [Freeswitch-users] Dialplan/PHP esl variable problem.

On 29/03/12 16:08, Peter Olsson wrote:

ESL execute is async, so you will need to wait for the correct event to be returned, that tells you it's finished. EXECUTE_COMPLETE I think the event is called..

/Peter

29 mar 2012 kl. 16:57 skrev "Alex Crow" <acrow at integrafin.co.uk><mailto:acrow at integrafin.co.uk>:



Peter,

Actually if execute is async the Wiki is wrong:

"execute

execute($app[, $arg][, $uuid])

Execute a dialplan application, and wait for a response from the server. On socket connections not anchored to a channel (most of the time inbound), all three arguments are required -- $uuid specifies the channel to execute the application on.

Returns an ESLevent object containing the response from the server. The getHeader("Reply-Text") method of this ESLevent object returns the server's response. The server's response will contain "+OK [Success Message]" on success or "-ERR [Error Message]" on failure.

See the examples below for information on how to get a uuid to use when calling execute().
executeAsync

executeAsync($app[, $arg][, $uuid])

Same as execute, but doesn't wait for a response from the server.

This works by causing the underlying call to execute() to append "async: true" header in the message sent to the channel. "

As you can see there is a specific executeAsync call documented. Are they both actually async?

That aside, does this code look OK?

$esl = new ESLconnection('localhost','8021','ClueCon');

$event = $esl->events('plain', 'ALL');
$event = $esl->filter("Unique-ID",$uuid);

sleep (2);

$event = $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");

//$foo = $uuid . ' target_num';


while ($event->getType() != 'CHANNEL_EXECUTE_COMPLETE' ) {
                $esl->execute("&sleep",100);
        }

$event=$esl->sendRecv("api uuid_getvar $uuid target_num");

Cheers

Alex

!DSPAM:4f7813f832766290219940!



Join us at ClueCon 2011 Aug 9-11, 2011
More information about the FreeSWITCH-users mailing list