when you do bgapi you actually have to subscribe to the background job event to get the results.<br>Since it&#39;s an async operation, the command is executed in it&#39;s own thread and when the results are collected they are put in the event&#39;s body.<br>
<br>The bgapi returns a job-uuid that you need to save and use it to tie the background_job event to the original request.<br><br>The decision to use api vs bgapi is weather or not you want to get the results right away or not.&nbsp; So usually show channels etc is a case where you want to do it in the foreground.<br>
<br>Also to further complicate things, bgapi is an event socket command only so it cannot be used from cli xml-rpc etc.<br>BUT, there is actually a *bgapi* FSAPI command you can execute to run any FSAPI in the same fashion.<br>
<br>so raw event socket command<br>api bgapi show channels<br><br>is the same as raw event socket command<br><br>bgapi show channels<br><br>but, you can also say &quot;bgapi show channels&quot; from the cli/xml-rpc/dialplan etc as well.<br>
<br><br><div class="gmail_quote">On Fri, May 16, 2008 at 1:08 AM, Michael Collins &lt;<a href="mailto:mcollins@fcnetwork.com">mcollins@fcnetwork.com</a>&gt; wrote:<br><blockquote class="gmail_quote" style="border-left: 1px solid rgb(204, 204, 204); margin: 0pt 0pt 0pt 0.8ex; padding-left: 1ex;">











<div link="blue" vlink="purple" lang="EN-US">

<div>

<p><font color="navy" face="Arial" size="2"><span style="font-size: 10pt; font-family: Arial; color: navy;">Followup question: I can use api to send "show
channels" or "oz list" but when I use bgapi to send those
commands I don't get anything back from the event socket. &nbsp;Any
thoughts?</span></font></p>

<p><font color="navy" face="Arial" size="2"><span style="font-size: 10pt; font-family: Arial; color: navy;">&nbsp;</span></font></p>

<p><font color="navy" face="Arial" size="2"><span style="font-size: 10pt; font-family: Arial; color: navy;">-MC</span></font></p>

<p><font color="navy" face="Arial" size="2"><span style="font-size: 10pt; font-family: Arial; color: navy;">&nbsp;</span></font></p>

<div style="border-style: none none none solid; border-color: -moz-use-text-color -moz-use-text-color -moz-use-text-color blue; border-width: medium medium medium 1.5pt; padding: 0in 0in 0in 4pt;">

<div>

<div style="text-align: center;" align="center"><font face="Times New Roman" size="3"><span style="font-size: 12pt;">

<hr align="center" size="2" width="100%">

</span></font></div>

<p><b><font face="Tahoma" size="2"><span style="font-size: 10pt; font-family: Tahoma; font-weight: bold;">From:</span></font></b><font face="Tahoma" size="2"><span style="font-size: 10pt; font-family: Tahoma;">
<a href="mailto:freeswitch-users-bounces@lists.freeswitch.org" target="_blank">freeswitch-users-bounces@lists.freeswitch.org</a>
[mailto:<a href="mailto:freeswitch-users-bounces@lists.freeswitch.org" target="_blank">freeswitch-users-bounces@lists.freeswitch.org</a>] <b><span style="font-weight: bold;">On Behalf Of </span></b>Michael
 Collins<br>
<b><span style="font-weight: bold;">Sent:</span></b> Thursday, May 15, 2008 4:59
PM<br>
<b><span style="font-weight: bold;">To:</span></b> <a href="mailto:freeswitch-users@lists.freeswitch.org" target="_blank">freeswitch-users@lists.freeswitch.org</a><br>
<b><span style="font-weight: bold;">Subject:</span></b> [Freeswitch-users] Event
socket: api vs. bgapi</span></font></p>

</div><div><div></div><div class="Wj3C7c">

<p><font face="Times New Roman" size="3"><span style="font-size: 12pt;">&nbsp;</span></font></p>

<p><font face="Arial" size="2"><span style="font-size: 10pt; font-family: Arial;">Question:</span></font></p>

<p><font face="Arial" size="2"><span style="font-size: 10pt; font-family: Arial;">&nbsp;</span></font></p>

<p><font face="Arial" size="2"><span style="font-size: 10pt; font-family: Arial;">Are there compelling reasons *<b><span style="font-weight: bold;">not</span></b>* to use api for simple commands like "show
channels" or "oz list"? &nbsp;Since api is blocking and bgapi
is non-blocking I just wondered if there are recommendations for when to use
each one. &nbsp;I can definitely see why you'd use bgapi for an
"originate" command. &nbsp;I didn't see anything on the wiki
that discussed when to use api vs. bgapi so I'll be happy to write up a
blurb on the recommended use of each one.</span></font></p>

<p><font face="Arial" size="2"><span style="font-size: 10pt; font-family: Arial;">&nbsp;</span></font></p>

<p><font face="Arial" size="2"><span style="font-size: 10pt; font-family: Arial;">Thanks,</span></font></p>

<p><font face="Arial" size="2"><span style="font-size: 10pt; font-family: Arial;">MC</span></font></p>

</div></div></div>

</div>

</div>


<br>_______________________________________________<br>
Freeswitch-users mailing list<br>
<a 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>
<br></blockquote></div><br><br clear="all"><br>-- <br>Anthony Minessale II<br><br>FreeSWITCH <a href="http://www.freeswitch.org/">http://www.freeswitch.org/</a><br>ClueCon <a href="http://www.cluecon.com/">http://www.cluecon.com/</a><br>
<br>AIM: anthm<br><a href="mailto:MSN%3Aanthony_minessale@hotmail.com">MSN:anthony_minessale@hotmail.com</a><br>GTALK/JABBER/<a href="mailto:PAYPAL%3Aanthony.minessale@gmail.com">PAYPAL:anthony.minessale@gmail.com</a><br>
IRC: <a href="http://irc.freenode.net">irc.freenode.net</a> #freeswitch<br><br>FreeSWITCH Developer Conference<br><a href="mailto:sip%3A888@conference.freeswitch.org">sip:888@conference.freeswitch.org</a><br><a href="http://iax:guest@conference.freeswitch.org/888">iax:guest@conference.freeswitch.org/888</a><br>
<a href="mailto:googletalk%3Aconf%2B888@conference.freeswitch.org">googletalk:conf+888@conference.freeswitch.org</a><br>pstn:213-799-1400