FS-4558: add uuid

This commit is contained in:
Raymond Chandler committed 2012-08-31 16:35:13 -04:00
1 parent 984b27c68d
commit 6ed3218f8a
3 files changed
+113 -9

No files matched your search

@@ -33,6 +33,7 @@
* Massimo Cetra <devel@navynet.it>
* Rupa Schomaker <rupa@rupa.com>
* Joseph Sullivan <jossulli@amazon.com>
* Raymond Chandler <intralanman@freeswitch.org>
*
*
* mod_commands.c -- Misc. Command Module
@@ -3131,6 +3132,49 @@ SWITCH_STANDARD_API(uuid_phone_event_function)
return SWITCH_STATUS_SUCCESS;
}
#define SEND_MESSAGE_SYNTAX "<uuid> <message>"
SWITCH_STANDARD_API(uuid_send_message_function)
{
switch_status_t status = SWITCH_STATUS_FALSE;
char *mycmd = NULL, *argv[2] = { 0 };
int argc = 0;
if (!zstr(cmd) && (mycmd = strdup(cmd))) {
argc = switch_separate_string(mycmd, ' ', argv, (sizeof(argv) / sizeof(argv[0])));
}
if (argc < 2) {
stream->write_function(stream, "-USAGE: %s\n", SEND_MESSAGE_SYNTAX);
goto end;
} else {
switch_core_session_message_t msg = { 0 };
switch_core_session_t *lsession = NULL;
msg.message_id = SWITCH_MESSAGE_INDICATE_MESSAGE;
msg.string_array_arg[2] = argv[1];
msg.from = __FILE__;
if ((lsession = switch_core_session_locate(argv[0]))) {
status = switch_core_session_receive_message(lsession, &msg);
switch_core_session_rwunlock(lsession);
} else {
stream->write_function(stream, "-ERR Unable to find session for UUID\n");
goto end;
}
}
if (status == SWITCH_STATUS_SUCCESS) {
stream->write_function(stream, "+OK Success\n");
} else {
stream->write_function(stream, "-ERR Operation Failed\n");
}
end:
switch_safe_free(mycmd);
return SWITCH_STATUS_SUCCESS;
}
#define INFO_SYNTAX "<uuid>"
SWITCH_STANDARD_API(uuid_send_info_function)
{
@@ -5638,6 +5682,7 @@ SWITCH_MODULE_LOAD_FUNCTION(mod_commands_load)
SWITCH_ADD_API(commands_api_interface, "uuid_getvar", "uuid_getvar", uuid_getvar_function, GETVAR_SYNTAX);
SWITCH_ADD_API(commands_api_interface, "uuid_hold", "hold", uuid_hold_function, HOLD_SYNTAX);
SWITCH_ADD_API(commands_api_interface, "uuid_kill", "Kill Channel", kill_function, KILL_SYNTAX);
SWITCH_ADD_API(commands_api_interface, "uuid_send_message", "Send MESSAGE to the endpoint", uuid_send_message_function, SEND_MESSAGE_SYNTAX);
SWITCH_ADD_API(commands_api_interface, "uuid_send_info", "Send info to the endpoint", uuid_send_info_function, INFO_SYNTAX);
SWITCH_ADD_API(commands_api_interface, "uuid_video_refresh", "Send video refresh.", uuid_video_refresh_function, VIDEO_REFRESH_SYNTAX);
SWITCH_ADD_API(commands_api_interface, "uuid_outgoing_answer", "Answer Outgoing Channel", outgoing_answer_function, OUTGOING_ANSWER_SYNTAX);