Skip to content

Commit 8165d27

Browse files
committed
Add callback to mqtt_list_subscribe_topic
This will allow user to use the information as per application requirement. passing handler as NULL will have same behaviour as previous API. Signed-off-by: Ajay Bhargav <[email protected]>
1 parent d14a301 commit 8165d27

File tree

2 files changed

+4
-2
lines changed

2 files changed

+4
-2
lines changed

mqttclient/mqttclient.c

Lines changed: 3 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -1468,8 +1468,7 @@ int mqtt_publish(mqtt_client_t* c, const char* topic_filter, mqtt_message_t* msg
14681468
RETURN_ERROR(rc);
14691469
}
14701470

1471-
1472-
int mqtt_list_subscribe_topic(mqtt_client_t* c)
1471+
int mqtt_list_subscribe_topic(mqtt_client_t* c, topiclist_hanndler_t handler)
14731472
{
14741473
int i = 0;
14751474

@@ -1488,6 +1487,8 @@ int mqtt_list_subscribe_topic(mqtt_client_t* c)
14881487
/* determine whether a node already exists by mqtt topic, but wildcards are not supported */
14891488
if (NULL != msg_handler->topic_filter) {
14901489
MQTT_LOG_I("mqtt-client:%d %s() -[%d] subscribe topic: %s", __LINE__, __FUNCTION__, ++i ,msg_handler->topic_filter);
1490+
if (handler)
1491+
handler(msg_handler->topic_filter, msg_handler->qos);
14911492
}
14921493
}
14931494

mqttclient/mqttclient.h

Lines changed: 1 addition & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -65,6 +65,7 @@ typedef struct message_data {
6565
typedef void (*interceptor_handler_t)(void* client, message_data_t* msg);
6666
typedef void (*message_handler_t)(void* client, message_data_t* msg);
6767
typedef void (*reconnect_handler_t)(void* client, void* reconnect_date);
68+
typedef void (*topiclist_hanndler_t)(const char *topicname, mqtt_qos_t qos);
6869

6970
typedef struct message_handlers {
7071
mqtt_list_t list;

0 commit comments

Comments
 (0)