[Freeswitch-dev] BACKGROUND_JOB event

Juan Jose Comellas juanjo at comellas.org
Mon Apr 28 18:45:43 EDT 2008


Whenever a call to a command is made using bgapi, a BACKGROUND_JOB
event is sent by FreeSWITCH when the command is completed. A
BACKGROUND_JOB event looks like this:

-------------- cut --------------
Content-Length: 614
Content-Type: text/event-plain

Job-UUID: d19f2410-1548-11dd-9eeb-0d886880e312
Job-Command: originate
Job-Command-Arg: sofia/default/user2.comellas%40192.168.1.40%3A5061%202001
Event-Name: BACKGROUND_JOB
Core-UUID: f17f3284-1543-11dd-9eeb-0d886880e312
FreeSWITCH-Hostname: comellas
FreeSWITCH-IPv4: 192.168.1.38
FreeSWITCH-IPv6: 127.0.0.1
Event-Date-Local: 2008-04-28%2014%3A30%3A47
Event-Date-GMT: Mon,%2028%20Apr%202008%2017%3A30%3A47%20GMT
Event-Date-timestamp: 1209403847575107
Event-Calling-File: mod_event_socket.c
Event-Calling-Function: api_exec
Event-Calling-Line-Number: 602
Content-Length: 41

+OK d19f45e4-1548-11dd-9eeb-0d886880e312
-------------- cut --------------

>From what MikeJ told me over IRC, the body of a BACKGROUND_JOB message
is actually a serialized event containing the response to the original
command. The problem is that the content-type of the message is the
same as that used by any normal event. This makes it difficult to have
a generic parser, because we have to analyze the body of the message
to determine whether we are dealing with a normal event or a
BACKGROUND_JOB. The other problem I see is that the body containing
the serialized event does not have a content-type of its own.

An example of a message with the above mentioned problems addressed
could look like this:

-------------- cut --------------
Content-Length: 643
Content-Type: text/background-response-wrapper-plain

Job-UUID: d19f2410-1548-11dd-9eeb-0d886880e312
Job-Command: originate
Job-Command-Arg: sofia/default/user2.comellas%40192.168.1.40%3A5061%202001
Event-Name: BACKGROUND_JOB
Core-UUID: f17f3284-1543-11dd-9eeb-0d886880e312
FreeSWITCH-Hostname: comellas
FreeSWITCH-IPv4: 192.168.1.38
FreeSWITCH-IPv6: 127.0.0.1
Event-Date-Local: 2008-04-28%2014%3A30%3A47
Event-Date-GMT: Mon,%2028%20Apr%202008%2017%3A30%3A47%20GMT
Event-Date-timestamp: 1209403847575107
Event-Calling-File: mod_event_socket.c
Event-Calling-Function: api_exec
Event-Calling-Line-Number: 602
Content-Type: api/background-response
Content-Length: 41

+OK d19f45e4-1548-11dd-9eeb-0d886880e312
-------------- cut --------------

What do you think? Is a change similar to what I propose feasible?



More information about the Freeswitch-dev mailing list