main/stasis.c: Added detail info for stasis show app cli
authorsungtae kim <sungtae@messagebird.com>
Wed, 10 Apr 2019 00:09:10 +0000 (02:09 +0200)
committersungtae kim <sungtae@messagebird.com>
Tue, 16 Apr 2019 20:28:00 +0000 (22:28 +0200)
Currently, the "stasis show app" cli doesn't give detail
of subscription/subscriber information.
Added more printings to show details.

ASTERISK-28378

Change-Id: If25a6f14fe4f622bfb37462e891333da1fdf875f

main/stasis.c

index 4ce7052..e8ce0c7 100644 (file)
@@ -2369,6 +2369,7 @@ static char *stasis_show_topic(struct ast_cli_entry *e, int cmd, struct ast_cli_
 {
        struct stasis_topic *topic;
        char print_time[32];
+       int i;
 
        switch (cmd) {
        case CLI_INIT:
@@ -2402,6 +2403,21 @@ static char *stasis_show_topic(struct ast_cli_entry *e, int cmd, struct ast_cli_
        ast_format_duration_hh_mm_ss(ast_tvnow().tv_sec - topic->creationtime->tv_sec, print_time, sizeof(print_time));
        ast_cli(a->fd, "Duration time: %s\n", print_time);
 
+       ao2_lock(topic);
+       ast_cli(a->fd, "\nSubscribers:\n");
+       for (i = 0; i < AST_VECTOR_SIZE(&topic->subscribers); i++) {
+               struct stasis_subscription *subscription_tmp = AST_VECTOR_GET(&topic->subscribers, i);
+               ast_cli(a->fd, "  UniqueID: %s, Topic: %s, Detail: %s\n",
+                               subscription_tmp->uniqueid, subscription_tmp->topic->name, subscription_tmp->topic->detail);
+       }
+
+       ast_cli(a->fd, "\nForwarded topics:\n");
+       for (i = 0; i < AST_VECTOR_SIZE(&topic->upstream_topics); i++) {
+               struct stasis_topic *topic_tmp = AST_VECTOR_GET(&topic->upstream_topics, i);
+               ast_cli(a->fd, "  Topic: %s, Detail: %s\n", topic_tmp->name, topic_tmp->detail);
+       }
+       ao2_unlock(topic);
+
        ao2_ref(topic, -1);
 
        return CLI_SUCCESS;