Hello All, <br><br>I have some problem with receiving and handling ESL events. <br><br>My code is like:<br><br>void handle_eslswitch_event_plain(esl_handle_t *handle, esl_event_t *event) <br>{<br> ... ...<br> TRACE_DEBUG("ESL event [%d] %s: UUID: %s", <br>
event->event_id, fs_get_event_header(event, "Event-Name"), uniqueid);<br> print_event(event);<br> ... ...<br>}<br><br>void handle_event(esl_handle_t *handle, esl_event_t *last_event)<br>
{<br> ... ...<br> if (!strcasecmp(type, "text/event-plain")) {<br> handle_eslswitch_event_plain(handle, handle->last_ievent);<br> }<br> ... ...<br>}<br><br>int main()<br>
{<br> ... ...<br> //receive from event socket<br> if (handle.last_event) handle_event(&handle, handle.last_event);<br> ... ...<br><br>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:<br>
<br><2011-07-29 14:25:29> [DEBUG] ESL event [8] CHANNEL_HANGUP_COMPLETE: UUID: f320e4a6-db23-46d0-8d89-9957eccbd4c9<br><2011-07-29 14:25:29> [DEBUG] RECV EVENT<br>Event-Name: CHANNEL_HANGUP_COMPLETE<br>Core-UUID: 26b77cba-8fdd-486d-90ec-6844bca58c72<br>
FreeSWITCH-Hostname: fs01<br>FreeSWITCH-IPv4: 10.1.1.46<br>FreeSWITCH-IPv6: ::1 <br>Event-Date-Local: 2011-07-29 14:25:29<br><br>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:<br>
<br><2011-07-29 14:25:29> [NOTICE] -ERR invalid session id [f320e4a6-db23-46d0-8d89-9957eccbd4c9]<br><2011-07-28 15:55:23> [DEBUG] ESL event [0] : UUID: <br><2011-07-28 15:55:23> [DEBUG] RECV EVENT<br>Content-Length: 6485<br>
Content-Type: text/event-plain<br><br>Event-Name: CHANNEL_HANGUP<br>Core-UUID: 26b77cba-8fdd-486d-90ec-6844bca58c72<br>FreeSWITCH-Hostname: fs01<br>FreeSWITCH-IPv4: 10.1.1.46<br>FreeSWITCH-IPv6: %3A%3A1<br>Event-Date-Local: 2011-07-28%2015%3A55%3A23<br>
<br>In the above case, both Event ID and UUID are invalid. <br><br>I think i need more information regarding how to use the data elements in ESL event, especially how to use the following:<br><br> char last_reply[1024];<br>
/*! Las command reply when called with esl_send_recv */<br> char last_sr_reply[1024];<br> /*! Last event received. Only populated when **save_event is NULL */<br> esl_event_t *last_event;<br> /*! Last event received when called by esl_send_recv */<br>
esl_event_t *last_sr_event;<br> /*! This will hold already processed events queued by esl_recv_event */<br> esl_event_t *race_event;<br> /*! Events that have content-type == text/plain and a body */<br> esl_event_t *last_ievent;<br>
<br>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?<br><br>Please kindly advice. <br><br>Thanks,<br>D.Ma<br>
<br><br><br>