* NEW [rest_api] add http sub api(incomplete now).
@@ -1920,6 +1920,38 @@ handle_subscribe_msg(cJSON *sub_obj, nng_socket *sock)
getNumberValue(sub_obj, item, "qos", qos, rv);
//TODO insert client with topic and qos to db_tree
+ uint32_t pid = 0;
+ struct hashmap_s *table = get_hashmap();
+ dbtree *db = get_broker_db();
+ if (0 != (pid = nano_hashmap_get(table, clientid, strlen(clientid)))) {
+#ifdef STATISTICS
+ // TODO
+#endif
+
+ int topic_index = 0;
+ int topic_len = 0;
+ char *topic_str = NULL;
+ bool topic_exist = false;
+ while (topic_index < topic_count) {
+ topic_str = topics[topic_index];
+ puts(topic_str);
+ topic_len = strlen(topic_str);
+
+ /* Add items which not included in dbhash */
+ topic_exist =
+ dbhash_check_topic(pid, topic_str);
+ if (!topic_exist) {
+ dbtree_insert_client(
+ db, topic_str, pid);
+
+ dbhash_insert_topic(pid, topic_str);
+ }
+
+ topic_index++;
+
+ }
+ }
+ dbtree_print(db);
if (topics) {
free(topics);
