]> git.ipfire.org Git - thirdparty/freeswitch.git/commitdiff
[mod_verto] verto.announce
authorAnthony Minessale <anthm@signalwire.com>
Thu, 11 Jun 2020 23:24:43 +0000 (23:24 +0000)
committerAndrey Volk <andywolk@gmail.com>
Sat, 23 Oct 2021 19:00:25 +0000 (22:00 +0300)
src/mod/endpoints/mod_verto/mod_verto.c

index 09e5043605f5ad89109d70715122f720b507de18..3a94f112c8e0902df04dab41e7e01a0f3623297f 100644 (file)
@@ -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, &params);
+                       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")) {