[Freeswitch-users] Can't receive CHANNEL_HANGUP_COMPLETE event when using mod_rtmp

王永涛 gggyniidt at gmail.com
Mon Oct 21 14:44:50 MSD 2013


Hi
I made some changes on testserver.c. Then I call a sipnumber from the
flex client to a x-lite client. When I hang up from the flex side, can
receive CHANNEL_HANGUP_COMPLETE event loop can be ended. When I hang up
from the x-lite  side, I can't receive CHANNEL_HANGUP_COMPLETE event and
loop can not be ended, the variable status value is ESL_BREAK.

Thanks.

Code is as follows

static void mycallback(esl_socket_t server_sock, esl_socket_t client_sock,
struct sockaddr_in *addr) {
esl_handle_t handle = {{0}};
int done = 0;
esl_status_t status;
time_t exp = 0;

esl_attach_handle(&handle, client_sock, addr);

esl_log(ESL_LOG_INFO, "Connected! %d\n", handle.sock);

esl_filter(&handle, "unique-id", esl_event_get_header(handle.info_event,
"caller-unique-id"));
esl_events(&handle, ESL_EVENT_TYPE_PLAIN, "CHANNEL_HANGUP_COMPLETE DTMF
CUSTOM");

esl_send_recv(&handle, "linger");


esl_execute(&handle, "set", "hangup_after_bridge=true", NULL);
esl_execute(&handle, "bridge", "user/1001 at 192.168.1.128", NULL);

int i=rand();
while((status = esl_recv_timed(&handle, 1000)) != ESL_FAIL) {
printf("Thread:%d\n", i);
if (done) {
if (time(NULL) >= exp) {
break;
}
} else if (status == ESL_SUCCESS) {
const char *type = esl_event_get_header(handle.last_event, "content-type");
if (type && !strcasecmp(type, "text/disconnect-notice")) {
const char *dispo = esl_event_get_header(handle.last_event,
"content-disposition");
esl_log(ESL_LOG_INFO, "Got a disconnection notice dispostion: [%s]\n",
dispo ? dispo : "");
if (dispo && !strcmp(dispo, "linger")) {
done = 1;
esl_log(ESL_LOG_INFO, "Waiting 5 seconds for any remaining events.\n");
exp = time(NULL) + 5;
}
}
}
}

esl_log(ESL_LOG_INFO, "Disconnected! %d\n", handle.sock);
esl_disconnect(&handle);
}
-------------- next part --------------
An HTML attachment was scrubbed...
URL: http://lists.freeswitch.org/pipermail/freeswitch-users/attachments/20131021/1a9d4b80/attachment-0001.html 


Join us at ClueCon 2013 Aug 6-8, 2013
More information about the FreeSWITCH-users mailing list