make event socket wait for hangup on outbound mode and send disconnect message
git-svn-id: http://svn.freeswitch.org/svn/freeswitch/trunk@10053 d0543943-73ff-0310-b7d9-9358b9ac24b2
This commit is contained in:
parent
adfa0d7969
commit
c109eee26e
|
@ -47,7 +47,7 @@ typedef enum {
|
|||
LFLAG_FULL = (1 << 4),
|
||||
LFLAG_MYEVENTS = (1 << 5),
|
||||
LFLAG_SESSION = (1 << 6),
|
||||
LFLAG_ASYNC = (1 << 7)
|
||||
LFLAG_ASYNC = (1 << 7),
|
||||
} event_flag_t;
|
||||
|
||||
typedef enum {
|
||||
|
@ -71,6 +71,7 @@ struct listener {
|
|||
switch_core_session_t *session;
|
||||
int lost_events;
|
||||
int lost_logs;
|
||||
int hup;
|
||||
switch_sockaddr_t *sa;
|
||||
char remote_ip[50];
|
||||
switch_port_t remote_port;
|
||||
|
@ -428,7 +429,13 @@ static switch_status_t read_packet(listener_t *listener, switch_event_t **event,
|
|||
return SWITCH_STATUS_FALSE;
|
||||
}
|
||||
|
||||
if (channel && !switch_channel_ready(channel)) {
|
||||
if (switch_test_flag(listener, LFLAG_MYEVENTS) && !listener->hup && channel && !switch_channel_ready(channel)) {
|
||||
listener->hup = 1;
|
||||
}
|
||||
|
||||
if (listener->hup == 2 ||
|
||||
((!switch_test_flag(listener, LFLAG_MYEVENTS) && !switch_test_flag(listener, LFLAG_EVENTS)) &&
|
||||
channel && !switch_channel_ready(channel)) ) {
|
||||
status = SWITCH_STATUS_FALSE;
|
||||
break;
|
||||
}
|
||||
|
@ -595,6 +602,14 @@ static switch_status_t read_packet(listener_t *listener, switch_event_t **event,
|
|||
switch_safe_free(listener->ebuf);
|
||||
|
||||
endloop:
|
||||
|
||||
if (listener->hup == 1 && pevent->event_id == SWITCH_EVENT_CHANNEL_HANGUP) {
|
||||
char *uuid = switch_event_get_header(pevent, "unique-id");
|
||||
if (!strcmp(uuid, switch_core_session_get_uuid(listener->session))) {
|
||||
listener->hup = 2;
|
||||
}
|
||||
}
|
||||
|
||||
switch_event_destroy(&pevent);
|
||||
}
|
||||
}
|
||||
|
@ -604,7 +619,17 @@ static switch_status_t read_packet(listener_t *listener, switch_event_t **event,
|
|||
}
|
||||
}
|
||||
|
||||
if (listener->sock) {
|
||||
char buf[512] = "";
|
||||
const char message[] = "Disconnected, goodbye!\nSee you at ClueCon http://www.cluecon.com!\n";
|
||||
int mlen = strlen(message);
|
||||
|
||||
switch_snprintf(buf, sizeof(buf), "Content-Type: text/disconnect-notice\nContent-Length %d\n\n", mlen);
|
||||
len = strlen(buf);
|
||||
switch_socket_send(listener->sock, buf, &len);
|
||||
len = mlen;
|
||||
switch_socket_send(listener->sock, message, &len);
|
||||
}
|
||||
|
||||
return status;
|
||||
|
||||
|
@ -1137,7 +1162,7 @@ static void *SWITCH_THREAD_FUNC listener_run(switch_thread_t *thread, void *obj)
|
|||
|
||||
switch_log_printf(SWITCH_CHANNEL_LOG, SWITCH_LOG_WARNING, "IP %s Rejected by acl %s\n", listener->remote_ip, prefs.acl[x]);
|
||||
|
||||
switch_snprintf(buf, sizeof(buf), "Content-Type: rude/rejection\nContent-Length %d\n\n", mlen);
|
||||
switch_snprintf(buf, sizeof(buf), "Content-Type: text/rude-rejection\nContent-Length %d\n\n", mlen);
|
||||
len = strlen(buf);
|
||||
switch_socket_send(listener->sock, buf, &len);
|
||||
len = mlen;
|
||||
|
|
Loading…
Reference in New Issue