我想在C++中实现MQTT客户端功能(它必须是线程安全的,并且能够订阅主题并发布,但是不需要代理功能)。
我正在考虑使用Eclipse的Paho MQTT。
Here是他们的下载页面。
我发现那里没有MQTT5.0支持。
但是,在他们的github上:有一个C++包装器,在1.1版中声明了对MQTTv5.0的支持。
然后我发现了这个问题:Mosquitto vs eclipse paho client library,结论是:
to use libmosquitto with libmosquittopp wrapper
我检查了libmosquittopp.h:所有功能都标记为已弃用,所以到目前为止,我认为这不是正确的方法。
为什么不推荐使用libmosquittopp?因为
The wrapper came about by an external request and at the time it was created there were no other C++ solutions for MQTT. This has changed in the past years and this wrapper provides no benefit over true C++ libraries or using the pure C libmosquitto.
那么,Paho现在是否被认为是在C++中使用MQTT的正确方向?
还是只使用Mosquitto的纯C库?
还是其他什么(除了从0开始写)?
最佳答案
Paho C++库确实支持MQTT v5,并且是线程安全的。您可以使用单个客户端连接从多个线程发布和订阅。
某些Eclipse网页需要使用最新功能进行更新。 GitHub存储库往往具有最新信息。
Paho C++库只是包装Paho C库,但是提供了异步的, future 风格的API,并通过共享指针提供了内存管理。
关于c++ - MQTT C++客户端,我们在Stack Overflow上找到一个类似的问题: https://stackoverflow.com/questions/61346851/