Hi! I'm new user to freeswitch.I write a c program to dial and play a wav file. I want to know hangup-cause.But it does not work.The Event-Name i got is "SOCKET_DATA" not "CHANNEL_HANGUP". Can you help me to fix it and get hangup-cause?<br>
<br>Then i will dial lot of number but only on work time (9:00-11:00,14:00-17:00).So I want to use crontab to send custom event to crotrol dial start or stop.So how to send and receive custom event ?<br>Beside the crotab and custom event,any other better idea to control when to start or stop ?<br>
<br>Thanks!<br><br>#include <stdio.h><br>#include <stdlib.h><br>#include <esl.h><br><br><br>int main(void)<br>{<br> esl_handle_t handle = {{0}};<br><br> esl_status_t status1,status2,status3;<br> int done = 0;<br>
esl_status_t status;<br> time_t exp = 0;<br><br> //esl_global_set_default_logger(7);<br> status1 = esl_connect(&handle, "localhost", 8021, NULL, "ClueCon");<br><br> esl_events(&handle, ESL_EVENT_TYPE_PLAIN, "CHANNEL_ANSWER CHANNEL_ORIGINATE CHANNEL_HANGUP");<br>
<br> status2 = esl_send_recv(&handle, "api originate user/1001 &playback(/tmp/a.wav)\n\n");<br> <br> if (handle.last_sr_event && handle.last_sr_event->body) {<br> printf("Sucess --- %s\n", handle.last_sr_event->body);<br>
} else {<br> // this is unlikely to happen with api or bgapi (which is hardcoded above) but prefix but may be true for other commands<br> printf("Fail --- %s\n", handle.last_sr_reply);<br> }<br>
<br> while((status = esl_recv_event(&handle, 1,NULL)) != ESL_FAIL)<br> {<br> if (status == ESL_SUCCESS) <br> {<br> char *type = esl_event_get_header(handle.last_event, "content-type");<br>
printf("--- %s\n", type);<br> printf("--- %s\n",esl_event_get_header(handle.last_event, "Event-Name"));<br> //next to get Hangup-Cause from Event-Name:CHANNEL_HANGUP<br>
}<br> }<br> esl_disconnect(&handle);<br> return 0;<br>}<br><br><br>[freeswitch@fs ~]$ ./test<br>Sucess --- +OK 3fe60603-0ed4-4a6d-9322-dd906433b3cc<br><br>--- text/event-plain<br>--- SOCKET_DATA<br>--- text/event-plain<br>
--- SOCKET_DATA<br>--- text/event-plain<br>--- SOCKET_DATA<br>--- text/event-plain<br>--- SOCKET_DATA<br>