When you execute a command you always get the reply to
that command before anything else. This means that
with something like the originate command you will
have to wait for the call to establish media to get the
reply.

There are however 2 ways to get async results.

The event socket uses the "api" command to interface
with the FSAPI interface (for originate, show, etc),
but there is also a bgapi command.

When using bgapi, a unique id is generated and returned
instantly as the result of the command and the desired
command is executed in it's own thread.  When that
command is finished it fires the event
SWITCH_EVENT_BACKGROUND_JOB

If you are subscribed to that event you can check the
header 'Job-UUID' and look for a match to the uuid
you were given when you executed the command.
The body of the event message will contain the command
output.

Also as of this week, since this was a useful feature,
I also created the bgapi FSAPI function which is the same
thing only implmented as an FSAPI command in mod_commands.
This allows you to execute background jobs from the cli
or xml-rpc etc.

so with event socket you can send:
bgapi show dialplan\n\n
bgapi show dialplan

Content-Type: command/reply
Reply-Text: +OK Job-UUID: 3cd1c51e-dac4-4cfc-8567-3a440673feed




if you are waiting for the background_job event you will
eventually get:



Job-UUID: 3cd1c51e-dac4-4cfc-8567-3a440673feed
Job-Command: show
Job-Command-Arg: dialplan
Event-Name: BACKGROUND_JOB
Core-UUID: d1a1f5b8-4f68-4406-97fa-89a597bb014a
FreeSWITCH-Hostname: mera.tollfreeexpress.com
FreeSWITCH-IPv4: 208.64.201.69
FreeSWITCH-IPv6: 127.0.0.1
Event-Date-Local: 2008-01-18%2009%3A18%3A25
Event-Date-GMT: Fri,%2018%20Jan%202008%2014%3A18%3A25%20GMT
Event-Date-timestamp: 1200665905784042
Event-Calling-File: mod_event_socket.c
Event-Calling-Function: api_exec
Event-Calling-Line-Number: 559
Content-Length: 65

type,name
dialplan,enum
dialplan,XML
dialplan,asterisk

3 total.




















 
Anthony Minessale II

FreeSWITCH http://www.freeswitch.org/
ClueCon http://www.cluecon.com/

AIM: anthm
MSN:anthony_minessale@hotmail.com
GTALK/JABBER/PAYPAL:anthony.minessale@gmail.com
IRC: irc.freenode.net #freeswitch

FreeSWITCH Developer Conference
sip:888@conference.freeswitch.org
iax:guest@conference.freeswitch.org/888
googletalk:conf+888@conference.freeswitch.org
pstn:213-799-1400


----- Original Message ----
From: Jonas Gauffin <jonas.gauffin@gmail.com>
To: freeswitch-users@lists.freeswitch.org
Sent: Thursday, January 17, 2008 9:42:17 AM
Subject: [Freeswitch-users] Event socket and commands/apis

Hello

Are the commands sent over the event socked handled synchronously or
asynchronously?
I mean, if I send two commands, can the first reply that I get back be
for the second command as it completed faster?

//Jonas

_______________________________________________
Freeswitch-users mailing list
Freeswitch-users@lists.freeswitch.org
http://lists.freeswitch.org/mailman/listinfo/freeswitch-users
UNSUBSCRIBE:http://lists.freeswitch.org/mailman/options/freeswitch-users
http://www.freeswitch.org



Never miss a thing. Make Yahoo your homepage.