[Freeswitch-users] Difference between ESL execute() and executeAsync()

Ron McLeod ron.freeswitch at mcleodnet.com
Sat Dec 19 17:29:31 PST 2009


I don't notice any different in behavior between execute() and
executeAsync().  I was expecting that executeAsync() would return
right-away, and that execute() would only return after the specified
application runs to completion (CHANNEL_EXECUTE_COMPLETE event).

Running the sample app below, I see the "About to call execute(playback)"
and "returned" displayed one right-after the other, even though the file
being played takes about 4 minutes to play-out.

Do I have this wrong, or is there something incorrect in my app?

APP:
#!/usr/bin/php
<?php
require_once "ESL.php";

$eventSocket = New ESLconnection('192.168.100.132', '8021', 'ClueCon');
$eventSocket->events('plain', 'CHANNEL_STATE');
$eventSocket->filter('channel-state', 'CS_ROUTING');

// Wait for new call attempts
while($eventSocket->connected()){
    $event = $eventSocket->recvEvent();
    $serializedBody = $event->serialize();
    $listOfLines = toArrayOfLines($serializedBody);
    $nameValuePairs = toArrayOfNameValuePairs($listOfLines);

    $uuid = $nameValuePairs['Caller-Unique-ID'];
    printf("New call from uuid: $uuid\n");

    // answer the caller and play announcement
    $eventSocket->execute('answer', Null ,$uuid);

    printf("About to call execute(playback)\n");
    $eventSocket->execute('playback', '/tmp/ann.wav', $uuid);
    printf("returned\n");
}
?>


DIALPLAN:
<?xml version="1.0" encoding="utf-8"?>
<include>
  <context name="mytest">
    <extension name="mytest">
      <condition field="destination_number" expression="^.*$">
        <action application="park"/>
      </condition>
    </extension>
  </context>
</include>





More information about the FreeSWITCH-users mailing list