[Freeswitch-users] How to use ESL event

David Ma mays.david at gmail.com
Tue Aug 2 20:32:18 MSD 2011


Hello All,

I have some problem with receiving and handling ESL events.

My code is like:

void handle_eslswitch_event_plain(esl_handle_t *handle, esl_event_t *event)
{
        ... ...
        TRACE_DEBUG("ESL event [%d] %s: UUID: %s",
                event->event_id, fs_get_event_header(event, "Event-Name"),
uniqueid);
         print_event(event);
        ... ...
}

void handle_event(esl_handle_t *handle, esl_event_t *last_event)
{
        ... ...
        if (!strcasecmp(type, "text/event-plain")) {
            handle_eslswitch_event_plain(handle, handle->last_ievent);
        }
        ... ...
}

int main()
{
        ... ...
        //receive from event socket
        if (handle.last_event) handle_event(&handle, handle.last_event);
        ... ...

Usually I receive correct events. But I occasionally receive incorrect
event. See below the 1st is the normal event and the 2nd is the wrong event:

<2011-07-29 14:25:29> [DEBUG] ESL event [8] CHANNEL_HANGUP_COMPLETE: UUID:
f320e4a6-db23-46d0-8d89-9957eccbd4c9
<2011-07-29 14:25:29> [DEBUG] RECV EVENT
Event-Name: CHANNEL_HANGUP_COMPLETE
Core-UUID: 26b77cba-8fdd-486d-90ec-6844bca58c72
FreeSWITCH-Hostname: fs01
FreeSWITCH-IPv4: 10.1.1.46
FreeSWITCH-IPv6: ::1
Event-Date-Local: 2011-07-29 14:25:29

However, usually after failure in executing "hangup" and getting "-ERR ..."
in the event->last_sr_reply, I have wrong event, but not always (an -ERR
returned from executing "hangup" doesn't always result in a wrong event).
Here it is:

<2011-07-29 14:25:29> [NOTICE] -ERR invalid session id
[f320e4a6-db23-46d0-8d89-9957eccbd4c9]
<2011-07-28 15:55:23> [DEBUG] ESL event [0] : UUID:
<2011-07-28 15:55:23> [DEBUG] RECV EVENT
Content-Length: 6485
Content-Type: text/event-plain

Event-Name: CHANNEL_HANGUP
Core-UUID: 26b77cba-8fdd-486d-90ec-6844bca58c72
FreeSWITCH-Hostname: fs01
FreeSWITCH-IPv4: 10.1.1.46
FreeSWITCH-IPv6: %3A%3A1
Event-Date-Local: 2011-07-28%2015%3A55%3A23

In the above case, both Event ID and UUID are invalid.

I think i need more information regarding how to use the data elements in
ESL event, especially how to use the following:

    char last_reply[1024];
    /*! Las command reply when called with esl_send_recv */
    char last_sr_reply[1024];
    /*! Last event received. Only populated when **save_event is NULL */
    esl_event_t *last_event;
    /*! Last event received when called by esl_send_recv */
    esl_event_t *last_sr_event;
    /*! This will hold already processed events queued by esl_recv_event */
    esl_event_t *race_event;
    /*! Events that have content-type == text/plain and a body */
    esl_event_t *last_ievent;

My questions, what event should I check if I am interested in only
channel/call related events, and how? Do I check handle.last_event, or
handle.last_ievent, or what?

Please kindly advice.

Thanks,
D.Ma
-------------- next part --------------
An HTML attachment was scrubbed...
URL: http://lists.freeswitch.org/pipermail/freeswitch-users/attachments/20110803/ff14b149/attachment.html 


Join us at ClueCon 2011 Aug 9-11, 2011
More information about the FreeSWITCH-users mailing list