From 465ba3d48ca9f59015204ffda063acd662aa89a6 Mon Sep 17 00:00:00 2001 From: Michael Jerris Date: Fri, 16 Nov 2007 20:20:43 +0000 Subject: [PATCH] a late gift for DT. git-svn-id: http://svn.freeswitch.org/svn/freeswitch/trunk@6313 d0543943-73ff-0310-b7d9-9358b9ac24b2 --- .../applications/mod_commands/mod_commands.c | 38 +++++++++++++++++++ 1 file changed, 38 insertions(+) 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 "[+]