From: Anthony Minessale Date: Thu, 11 Aug 2016 15:41:42 +0000 (-0500) Subject: FS-9419 #resolve [Add event_channel_broadcast api] X-Git-Tag: v1.6.10~1^2~37 X-Git-Url: http://git.ipfire.org/cgi-bin/gitweb.cgi?a=commitdiff_plain;h=48cec71c7635ad2d353908b825dc0ae8ae2dd1dd;p=thirdparty%2Ffreeswitch.git FS-9419 #resolve [Add event_channel_broadcast api] --- diff --git a/src/mod/applications/mod_commands/mod_commands.c b/src/mod/applications/mod_commands/mod_commands.c index 135896e60f..64d25dd315 100644 --- a/src/mod/applications/mod_commands/mod_commands.c +++ b/src/mod/applications/mod_commands/mod_commands.c @@ -6900,6 +6900,38 @@ SWITCH_STANDARD_JSON_API(json_execute_function) return status; } +SWITCH_STANDARD_API(event_channel_broadcast_api_function) +{ + cJSON *jdata = NULL; + const char *channel; + + if (!cmd) { + stream->write_function(stream, "-ERR parsing channel\n", SWITCH_VA_NONE); + return SWITCH_STATUS_SUCCESS; + } + + if (!(jdata = cJSON_Parse(cmd))) { + stream->write_function(stream, "-ERR parsing json\n"); + } + + + if (jdata) { + if (!(channel = cJSON_GetObjectCstr(jdata, "eventChannel"))) { + switch_log_printf(SWITCH_CHANNEL_LOG, SWITCH_LOG_ERROR, "NO EVENT CHANNEL SPECIFIED\n"); + } else { + switch_event_channel_broadcast(channel, &jdata, modname, NO_EVENT_CHANNEL_ID); + stream->write_function(stream, "+OK message sent\n", SWITCH_VA_NONE); + } + + if (jdata) { + cJSON_Delete(jdata); + } + } + + return SWITCH_STATUS_SUCCESS; + +} + SWITCH_STANDARD_JSON_API(json_api_function) { cJSON *data, *cmd, *arg, *reply; @@ -7090,6 +7122,7 @@ SWITCH_MODULE_LOAD_FUNCTION(mod_commands_load) SWITCH_ADD_API(commands_api_interface, "db_cache", "Manage db cache", db_cache_function, "status"); SWITCH_ADD_API(commands_api_interface, "domain_exists", "Check if a domain exists", domain_exists_function, ""); SWITCH_ADD_API(commands_api_interface, "echo", "Echo", echo_function, ""); + SWITCH_ADD_API(commands_api_interface, "event_channel_broadcast", "Broadcast", event_channel_broadcast_api_function, " "); SWITCH_ADD_API(commands_api_interface, "escape", "Escape a string", escape_function, ""); SWITCH_ADD_API(commands_api_interface, "eval", "eval (noop)", eval_function, "[uuid: ]"); SWITCH_ADD_API(commands_api_interface, "expand", "Execute an api with variable expansion", expand_function, "[uuid: ] ");