Mqtt 如何控制mosquitto_loop()来订阅消息?
我想要一个关于mosquittopp循环的示例 我的代码是:Mqtt 如何控制mosquitto_loop()来订阅消息?,mqtt,mosquitto,Mqtt,Mosquitto,我想要一个关于mosquittopp循环的示例 我的代码是: MqttWrapper *mqttHdl = new MqttWrapper("sanggil", "***.**.**.***", 1883); int rc; while(1){ rc = mqttHdl->loop(); printf( "while %d\n", rc); if(rc){ mqttHdl->reconnect
MqttWrapper *mqttHdl = new MqttWrapper("sanggil", "***.**.**.***", 1883);
int rc;
while(1){
rc = mqttHdl->loop();
printf( "while %d\n", rc);
if(rc){
mqttHdl->reconnect();
}
}
我在项目中使用了C++的C++代码库中的示例代码。 因为它在主功能中有while功能,所以我的项目中的其他代码不能正常工作。 而函数大约每秒调用一次
我只想在一些消息只从没有循环的代理收到时调用subcribe函数 我是否必须使用while函数来侦听来自代理的消息如果我使用while函数,它将使用程序中的大部分资源。启动一个单独的线程来运行moquitto\u循环函数