diff options
author | Timotej S <6674623+underhood@users.noreply.github.com> | 2022-12-13 12:32:05 +0700 |
---|---|---|
committer | GitHub <noreply@github.com> | 2022-12-13 12:32:05 +0700 |
commit | a749ab00a63b229d99f6bc82a965206e5481db3e (patch) | |
tree | 6d5ad0676338a7e6c1ce767229befb7249d2a246 /aclk | |
parent | 340459e43c1d286a5f08232b51185b06874ddbf5 (diff) |
MQTT 5 publish topic alias support (#14067)
* mqtt_websockets bumps version
* use the new topic alias support in netdata
Diffstat (limited to 'aclk')
-rw-r--r-- | aclk/aclk.c | 4 | ||||
-rw-r--r-- | aclk/aclk_util.c | 18 | ||||
-rw-r--r-- | aclk/aclk_util.h | 4 |
3 files changed, 26 insertions, 0 deletions
diff --git a/aclk/aclk.c b/aclk/aclk.c index fb47f2347b..8822fa816c 100644 --- a/aclk/aclk.c +++ b/aclk/aclk.c @@ -365,6 +365,10 @@ static inline void mqtt_connected_actions(mqtt_wss_client client) aclk_rcvd_cloud_msgs = 0; aclk_connection_counter++; + aclk_topic_cache_iter_t iter = ACLK_TOPIC_CACHE_ITER_T_INITIALIZER; + while ((topic = (char*)aclk_topic_cache_iterate(&iter)) != NULL) + mqtt_wss_set_topic_alias(client, topic); + aclk_send_agent_connection_update(client, 1); } diff --git a/aclk/aclk_util.c b/aclk/aclk_util.c index 01eaedc8e0..b6eea87c16 100644 --- a/aclk/aclk_util.c +++ b/aclk/aclk_util.c @@ -308,6 +308,24 @@ const char *aclk_get_topic(enum aclk_topics topic) } /* + * Allows iterating all topics in topic cache without + * having to resort to callbacks. + */ + +const char *aclk_topic_cache_iterate(aclk_topic_cache_iter_t *iter) +{ + if (!aclk_topic_cache) { + error("Topic cache not initialized when %s was called.", __FUNCTION__); + return NULL; + } + + if (*iter >= aclk_topic_cache_items) + return NULL; + + return aclk_topic_cache[(*iter)++]->topic; +} + +/* * TBEB with randomness * * @param reset 1 - to reset the delay, diff --git a/aclk/aclk_util.h b/aclk/aclk_util.h index ed715e0466..b858fe7383 100644 --- a/aclk/aclk_util.h +++ b/aclk/aclk_util.h @@ -93,9 +93,13 @@ enum aclk_topics { ACLK_TOPICID_CTXS_UPDATED = 20 }; +typedef size_t aclk_topic_cache_iter_t; +#define ACLK_TOPIC_CACHE_ITER_T_INITIALIZER (0) + const char *aclk_get_topic(enum aclk_topics topic); int aclk_generate_topic_cache(struct json_object *json); void free_topic_cache(void); +const char *aclk_topic_cache_iterate(aclk_topic_cache_iter_t *iter); // TODO // aclk_topics_reload //when claim id changes |