git-svn-id: http://svn.freeswitch.org/svn/freeswitch/trunk@10158 d0543943-73ff-0310-b7d9-9358b9ac24b2
This commit is contained in:
Anthony Minessale 2008-10-26 21:08:22 +00:00
parent ae124bfb4f
commit 6b48e82663

View File

@ -1048,6 +1048,33 @@ static switch_status_t parse_command(listener_t *listener, switch_event_t **even
switch_snprintf(reply, reply_len, "+OK"); switch_snprintf(reply, reply_len, "+OK");
goto done; goto done;
} else if (listener->session && !strncasecmp(cmd, "sendmsg", 7)) { } else if (listener->session && !strncasecmp(cmd, "sendmsg", 7)) {
char *uuid = cmd + 8;
switch_core_session_t *session = NULL;
if (uuid) {
while (*uuid == ' ') {
uuid++;
}
if (*uuid == '\r' || *uuid == '\n') {
uuid = NULL;
} else {
strip_cr(uuid);
}
}
if (!uuid) {
uuid = switch_event_get_header(*event, "session-id");
}
if (uuid && (session = switch_core_session_locate(uuid))) {
if ((status = switch_core_session_queue_private_event(session, event)) == SWITCH_STATUS_SUCCESS) {
switch_snprintf(reply, reply_len, "+OK");
} else {
switch_snprintf(reply, reply_len, "-ERR memory error");
}
switch_core_session_rwunlock(session);
} else {
if (switch_test_flag(listener, LFLAG_ASYNC)) { if (switch_test_flag(listener, LFLAG_ASYNC)) {
if ((status = switch_core_session_queue_private_event(listener->session, event)) == SWITCH_STATUS_SUCCESS) { if ((status = switch_core_session_queue_private_event(listener->session, event)) == SWITCH_STATUS_SUCCESS) {
switch_snprintf(reply, reply_len, "+OK"); switch_snprintf(reply, reply_len, "+OK");
@ -1058,6 +1085,7 @@ static switch_status_t parse_command(listener_t *listener, switch_event_t **even
switch_ivr_parse_event(listener->session, *event); switch_ivr_parse_event(listener->session, *event);
switch_snprintf(reply, reply_len, "+OK"); switch_snprintf(reply, reply_len, "+OK");
} }
}
goto done; goto done;
} else if (!strncasecmp(cmd, "getvar", 6)) { } else if (!strncasecmp(cmd, "getvar", 6)) {
char *arg; char *arg;
@ -1174,7 +1202,7 @@ static switch_status_t parse_command(listener_t *listener, switch_event_t **even
uuid = switch_event_get_header(*event, "session-id"); uuid = switch_event_get_header(*event, "session-id");
} }
if ((session = switch_core_session_locate(uuid))) { if (uuid && (session = switch_core_session_locate(uuid))) {
if ((status = switch_core_session_queue_private_event(session, event)) == SWITCH_STATUS_SUCCESS) { if ((status = switch_core_session_queue_private_event(session, event)) == SWITCH_STATUS_SUCCESS) {
switch_snprintf(reply, reply_len, "+OK"); switch_snprintf(reply, reply_len, "+OK");
} else { } else {
@ -1182,7 +1210,7 @@ static switch_status_t parse_command(listener_t *listener, switch_event_t **even
} }
switch_core_session_rwunlock(session); switch_core_session_rwunlock(session);
} else { } else {
switch_snprintf(reply, reply_len, "-ERR invalid session id [%s]", uuid); switch_snprintf(reply, reply_len, "-ERR invalid session id [%s]", switch_str_nil(uuid));
} }
goto done; goto done;