<html><head><style type="text/css"><!-- DIV {margin:0px;} --></style></head><body><div style="font-family:courier,monaco,monospace,sans-serif;font-size:12pt">When you execute a command you always get the reply to<br>that command before anything else. This means that <br>with something like the originate command you will<br>have to wait for the call to establish media to get the <br>reply.<br><br>There are however 2 ways to get async results.<br><br>The event socket uses the "api" command to interface<br>with the FSAPI interface (for originate, show, etc),<br>but there is also a bgapi command.<br><br>When using bgapi, a unique id is generated and returned<br>instantly as the result of the command and the desired <br>command is executed in it's own thread.&nbsp; When that <br>command is finished it fires the event <br>SWITCH_EVENT_BACKGROUND_JOB<br><br>If you are subscribed to that event you can check the<br>header 'Job-UUID' and look for a match to the
 uuid<br>you were given when you executed the command.<br>The body of the event message will contain the command<br>output.<br><br>Also as of this week, since this was a useful feature,<br>I also created the bgapi FSAPI function which is the same<br>thing only implmented as an FSAPI command in mod_commands.<br>This allows you to execute background jobs from the cli<br>or xml-rpc etc.<br><br>so with event socket you can send:<br>bgapi show dialplan\n\n<br>bgapi show dialplan<br><br>Content-Type: command/reply<br>Reply-Text: +OK Job-UUID: 3cd1c51e-dac4-4cfc-8567-3a440673feed<br><br><br><br><br>if you are waiting for the background_job event you will<br>eventually get:<br><br><br><br>Job-UUID: 3cd1c51e-dac4-4cfc-8567-3a440673feed<br>Job-Command: show<br>Job-Command-Arg: dialplan<br>Event-Name: BACKGROUND_JOB<br>Core-UUID: d1a1f5b8-4f68-4406-97fa-89a597bb014a<br>FreeSWITCH-Hostname: mera.tollfreeexpress.com<br>FreeSWITCH-IPv4:
 208.64.201.69<br>FreeSWITCH-IPv6: 127.0.0.1<br>Event-Date-Local: 2008-01-18%2009%3A18%3A25<br>Event-Date-GMT: Fri,%2018%20Jan%202008%2014%3A18%3A25%20GMT<br>Event-Date-timestamp: 1200665905784042<br>Event-Calling-File: mod_event_socket.c<br>Event-Calling-Function: api_exec<br>Event-Calling-Line-Number: 559<br>Content-Length: 65<br><br>type,name<br>dialplan,enum<br>dialplan,XML<br>dialplan,asterisk<br><br>3 total.<br><br><br><br><br><br><br><br><br><br><br><br><br><br><br><br><br><br><br><br><br><div>&nbsp;</div><div>Anthony Minessale II<br><br><span>FreeSWITCH <a target="_blank" href="http://www.freeswitch.org/">http://www.freeswitch.org/</a></span><br><span>ClueCon <a target="_blank" href="http://www.cluecon.com/">http://www.cluecon.com/</a></span><br><br>AIM: anthm<br>MSN:anthony_minessale@hotmail.com<br>GTALK/JABBER/PAYPAL:anthony.minessale@gmail.com<br>IRC: irc.freenode.net #freeswitch</div><div><br>FreeSWITCH Developer
 Conference<br>sip:888@conference.freeswitch.org<br>iax:guest@conference.freeswitch.org/888<br>googletalk:conf+888@conference.freeswitch.org<br>pstn:213-799-1400</div><div style="font-family: courier,monaco,monospace,sans-serif; font-size: 12pt;"><br><br><div style="font-family: times new roman,new york,times,serif; font-size: 12pt;">----- Original Message ----<br>From: Jonas Gauffin &lt;jonas.gauffin@gmail.com&gt;<br>To: freeswitch-users@lists.freeswitch.org<br>Sent: Thursday, January 17, 2008 9:42:17 AM<br>Subject: [Freeswitch-users] Event socket and commands/apis<br><br>
Hello<br><br>Are the commands sent over the event socked handled synchronously or<br>asynchronously?<br>I mean, if I send two commands, can the first reply that I get back be<br>for the second command as it completed faster?<br><br>//Jonas<br><br>_______________________________________________<br>Freeswitch-users mailing list<br><a ymailto="mailto:Freeswitch-users@lists.freeswitch.org" href="mailto:Freeswitch-users@lists.freeswitch.org">Freeswitch-users@lists.freeswitch.org</a><br><a href="http://lists.freeswitch.org/mailman/listinfo/freeswitch-users" target="_blank">http://lists.freeswitch.org/mailman/listinfo/freeswitch-users</a><br>UNSUBSCRIBE:<a href="http://lists.freeswitch.org/mailman/options/freeswitch-users" target="_blank">http://lists.freeswitch.org/mailman/options/freeswitch-users</a><br><a href="http://www.freeswitch.org" target="_blank">http://www.freeswitch.org</a><br></div><br></div></div><br>

      <hr size=1>Never miss a thing.  <a href="http://us.rd.yahoo.com/evt=51438/*http://www.yahoo.com/r/hs"> Make Yahoo your homepage.</a>

</body></html>