From 650393fb90f79cfbbe9bc4b89f0d0dbdd9e9c3da Mon Sep 17 00:00:00 2001 From: Anthony Minessale Date: Wed, 29 Dec 2010 13:15:14 -0600 Subject: [PATCH] add recovery_refresh app and api and use it in mod_conference to send a message to the channel telling it to sync its recovery snapshot --- src/include/switch_types.h | 1 + .../applications/mod_commands/mod_commands.c | 36 +++++++++++++++++++ .../mod_conference/mod_conference.c | 6 ++++ .../applications/mod_dptools/mod_dptools.c | 12 +++++++ src/mod/endpoints/mod_sofia/mod_sofia.c | 2 ++ 5 files changed, 57 insertions(+) diff --git a/src/include/switch_types.h b/src/include/switch_types.h index 830ea409e8..bb5f59865f 100644 --- a/src/include/switch_types.h +++ b/src/include/switch_types.h @@ -791,6 +791,7 @@ typedef enum { SWITCH_MESSAGE_INDICATE_UDPTL_MODE, SWITCH_MESSAGE_INDICATE_CLEAR_PROGRESS, SWITCH_MESSAGE_INDICATE_JITTER_BUFFER, + SWITCH_MESSAGE_INDICATE_RECOVERY_REFRESH, SWITCH_MESSAGE_INVALID } switch_core_session_message_types_t; diff --git a/src/mod/applications/mod_commands/mod_commands.c b/src/mod/applications/mod_commands/mod_commands.c index 1c2e3ebfb9..8daaace7f3 100644 --- a/src/mod/applications/mod_commands/mod_commands.c +++ b/src/mod/applications/mod_commands/mod_commands.c @@ -2226,6 +2226,40 @@ SWITCH_STANDARD_API(uuid_deflect) return SWITCH_STATUS_SUCCESS; } +#define UUID_RECOVERY_REFRESH_SYNTAX " " +SWITCH_STANDARD_API(uuid_recovery_refresh) +{ + switch_core_session_t *tsession = NULL; + char *uuid = NULL, *text = NULL; + + if (!zstr(cmd) && (uuid = strdup(cmd))) { + if ((text = strchr(uuid, ' '))) { + *text++ = '\0'; + } + } + + if (zstr(uuid) || zstr(text)) { + stream->write_function(stream, "-USAGE: %s\n", UUID_RECOVERY_REFRESH_SYNTAX); + } else { + if ((tsession = switch_core_session_locate(uuid))) { + switch_core_session_message_t msg = { 0 }; + + /* Tell the channel to recovery_refresh the call */ + msg.from = __FILE__; + msg.string_arg = text; + msg.message_id = SWITCH_MESSAGE_INDICATE_RECOVERY_REFRESH; + switch_core_session_receive_message(tsession, &msg); + stream->write_function(stream, "+OK:%s\n", msg.string_reply); + switch_core_session_rwunlock(tsession); + } else { + stream->write_function(stream, "-ERR No Such Channel %s!\n", uuid); + } + } + + switch_safe_free(uuid); + return SWITCH_STATUS_SUCCESS; +} + #define SCHED_TRANSFER_SYNTAX "[+]