mqtt mid 说明
查看函数:int mosquitto_publish(struct mosquitto *mosq,int *mid,const char *topic,int payloadlen,const void * payload,int qos,bool retain)
关于mid的说明
mid pointer to an int. If not NULL, the function will set this to the message id of this particular message. This can be then used with the publish callback to determine when the message has been sent. Note that although the MQTT protocol doesn’t use message ids for messages with QoS=0, libmosquitto assigns them message ids so they can be tracked with this parameter.
大致意思就是可以在回调函数中跟踪到本条信息具体发送时间。即使用QoS为0的情况下,也能正常跟踪。
同样,在mosquitto_sub中也有这个功能。
mid a pointer to an int. If not NULL, the function will set this to the message id of this particular message. This can be then used with the subscribe callback to determine when the message has been sent.
都是在回调函数中使用。
on_subscribe(struct mosquitto *mq, void *obj, int mid, int qos_count, const int * granted_qos)
本文链接地址:https://const.net.cn/257.html