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@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