add uuid to event socket apps

This commit is contained in:
Anthony Minessale 2012-07-02 14:55:45 -05:00
parent 6068534c8e
commit 3708c96257
3 changed files with 25 additions and 2 deletions

View File

@ -2101,6 +2101,10 @@ static switch_status_t parse_command(listener_t *listener, switch_event_t **even
if (!strncasecmp(cmd, "sendevent", 9)) {
char *ename;
const char *uuid = NULL;
char uuid_str[SWITCH_UUID_FORMATTED_LENGTH + 1];
switch_uuid_str(uuid_str, sizeof(uuid_str));
switch_event_add_header_string(*event, SWITCH_STACK_BOTTOM, "Event-UUID", uuid_str);
strip_cr(cmd);
@ -2128,6 +2132,7 @@ static switch_status_t parse_command(listener_t *listener, switch_event_t **even
if ((uuid = switch_event_get_header(*event, "unique-id"))) {
switch_core_session_t *dsession;
if ((dsession = switch_core_session_locate(uuid))) {
switch_core_session_queue_event(dsession, event);
switch_core_session_rwunlock(dsession);
@ -2137,7 +2142,7 @@ static switch_status_t parse_command(listener_t *listener, switch_event_t **even
if (*event) {
switch_event_fire(event);
}
switch_snprintf(reply, reply_len, "+OK");
switch_snprintf(reply, reply_len, "+OK %s", uuid_str);
goto done;
} else if (!strncasecmp(cmd, "api ", 4)) {
struct api_command_struct acs = { 0 };

View File

@ -2221,10 +2221,19 @@ SWITCH_DECLARE(switch_status_t) switch_core_session_exec(switch_core_session_t *
const char *var;
switch_channel_t *channel = switch_core_session_get_channel(session);
char *expanded = NULL;
const char *app;
const char *app, *app_uuid_var;
switch_core_session_message_t msg = { 0 };
char delim = ',';
int scope = 0;
char uuid_str[SWITCH_UUID_FORMATTED_LENGTH + 1];
char *app_uuid = uuid_str;
if ((app_uuid_var = switch_channel_get_variable(channel, "app_uuid"))) {
app_uuid = (char *)app_uuid_var;
switch_channel_set_variable(channel, "app_uuid", NULL);
} else {
switch_uuid_str(uuid_str, sizeof(uuid_str));
}
switch_assert(application_interface);
@ -2304,6 +2313,7 @@ SWITCH_DECLARE(switch_status_t) switch_core_session_exec(switch_core_session_t *
switch_channel_event_set_data(session->channel, event);
switch_event_add_header_string(event, SWITCH_STACK_BOTTOM, "Application", application_interface->interface_name);
switch_event_add_header_string(event, SWITCH_STACK_BOTTOM, "Application-Data", expanded);
switch_event_add_header_string(event, SWITCH_STACK_BOTTOM, "Application-UUID", app_uuid);
switch_event_fire(&event);
}
@ -2327,6 +2337,7 @@ SWITCH_DECLARE(switch_status_t) switch_core_session_exec(switch_core_session_t *
switch_event_add_header_string(event, SWITCH_STACK_BOTTOM, "Application", application_interface->interface_name);
switch_event_add_header_string(event, SWITCH_STACK_BOTTOM, "Application-Data", expanded);
switch_event_add_header_string(event, SWITCH_STACK_BOTTOM, "Application-Response", resp ? resp : "_none_");
switch_event_add_header_string(event, SWITCH_STACK_BOTTOM, "Application-UUID", app_uuid);
switch_event_fire(&event);
}

View File

@ -530,6 +530,7 @@ SWITCH_DECLARE(switch_status_t) switch_ivr_parse_event(switch_core_session_t *se
if (cmd_hash == CMD_EXECUTE) {
char *app_name = switch_event_get_header(event, "execute-app-name");
char *event_uuid = switch_event_get_header(event, "event-uuid");
char *app_arg = switch_event_get_header(event, "execute-app-arg");
char *content_type = switch_event_get_header(event, "content-type");
char *loop_h = switch_event_get_header(event, "loops");
@ -598,6 +599,12 @@ SWITCH_DECLARE(switch_status_t) switch_ivr_parse_event(switch_core_session_t *se
switch_log_printf(SWITCH_CHANNEL_SESSION_LOG(session), SWITCH_LOG_DEBUG, "%s Command Execute %s(%s)\n",
switch_channel_get_name(channel), app_name, switch_str_nil(app_arg));
b4 = switch_micro_time_now();
if (event_uuid) {
switch_channel_set_variable(channel, "app_uuid", event_uuid);
}
if (switch_core_session_execute_application(session, app_name, app_arg) != SWITCH_STATUS_SUCCESS) {
if (!inner || switch_channel_test_flag(channel, CF_STOP_BROADCAST)) switch_channel_clear_flag(channel, CF_BROADCAST);
goto done;