From d197db060169772b6249b2f97cc8924a2e757ccd Mon Sep 17 00:00:00 2001 From: Anthony Minessale Date: Thu, 11 Jun 2020 23:24:43 +0000 Subject: [PATCH] [mod_verto] verto.announce --- src/mod/endpoints/mod_verto/mod_verto.c | 34 +++++++++++++++++++++++++ 1 file changed, 34 insertions(+) diff --git a/src/mod/endpoints/mod_verto/mod_verto.c b/src/mod/endpoints/mod_verto/mod_verto.c index 09e5043605..3a94f112c8 100644 --- a/src/mod/endpoints/mod_verto/mod_verto.c +++ b/src/mod/endpoints/mod_verto/mod_verto.c @@ -5363,6 +5363,38 @@ static switch_status_t cmd_status(char **argv, int argc, switch_stream_handle_t return SWITCH_STATUS_SUCCESS; } +static switch_status_t cmd_announce(char **argv, int argc, switch_stream_handle_t *stream) +{ + verto_profile_t *profile = NULL; + jsock_t *jsock; + + switch_mutex_lock(verto_globals.mutex); + for(profile = verto_globals.profile_head; profile; profile = profile->next) { + + switch_mutex_lock(profile->mutex); + for (jsock = profile->jsock_head; jsock; jsock = jsock->next) { + cJSON *params = NULL; + cJSON *array, *msg = jrpc_new_req("verto.announce", 0, ¶ms); + int i; + + array = cJSON_CreateArray(); + + for (i = 0; i < argc; i++) { + cJSON_AddItemToArray(array, cJSON_CreateString(argv[i])); + } + + cJSON_AddItemToObject(params, "msg", array); + jsock_queue_event(jsock, &msg, SWITCH_TRUE); + } + switch_mutex_unlock(profile->mutex); + } + switch_mutex_unlock(verto_globals.mutex); + + stream->write_function(stream, "+OK\n"); + + return SWITCH_STATUS_SUCCESS; +} + static switch_status_t cmd_xml_status(char **argv, int argc, switch_stream_handle_t *stream) { verto_profile_t *profile = NULL; @@ -5527,6 +5559,8 @@ SWITCH_STANDARD_API(verto_function) } status = SWITCH_STATUS_SUCCESS; goto done; + } else if (!strcasecmp(argv[0], "announce")) { + func = cmd_announce; } else if (!strcasecmp(argv[0], "status")) { func = cmd_status; } else if (!strcasecmp(argv[0], "xmlstatus")) {