diff --git a/src/mod/applications/mod_commands/mod_commands.c b/src/mod/applications/mod_commands/mod_commands.c index afc1a09a1f..075026850f 100644 --- a/src/mod/applications/mod_commands/mod_commands.c +++ b/src/mod/applications/mod_commands/mod_commands.c @@ -583,6 +583,43 @@ SWITCH_STANDARD_API(uuid_function) return SWITCH_STATUS_SUCCESS; } +#define UUID_CHAT_SYNTAX " " +SWITCH_STANDARD_API(uuid_chat) +{ + switch_core_session_t *tsession = NULL; + char *uuid = NULL, *text = NULL; + + if (!switch_strlen_zero(cmd) && (uuid = strdup(cmd))) { + if ((text = strchr(uuid, ' '))) { + *text++ = '\0'; + } + } + + if (switch_strlen_zero(uuid) || switch_strlen_zero(text)) { + stream->write_function(stream, "USAGE: %s\n", UUID_CHAT_SYNTAX); + } else { + if ((tsession = switch_core_session_locate(uuid))) { + switch_event_t *event; + if (switch_event_create(&event, SWITCH_EVENT_MESSAGE) == SWITCH_STATUS_SUCCESS) { + switch_event_add_body(event, "%s", text); + if (switch_core_session_receive_event(tsession, &event) != SWITCH_STATUS_SUCCESS) { + switch_event_destroy(&event); + stream->write_function(stream, "Send Failed\n"); + } else { + stream->write_function(stream, "OK\n"); + } + } + switch_core_session_rwunlock(tsession); + } else { + stream->write_function(stream, "No Such Channel %s!\n", uuid); + } + } + + switch_safe_free(uuid); + return SWITCH_STATUS_SUCCESS; +} + + #define SCHED_TRANSFER_SYNTAX "[+]