Qmqtt publish delaying problem
Unsolved
General and Desktop
-
Hi,
I am using qmqtt in a for loop with sleep 1 second and then process waiting to send messages until all 20 messages published.
When the loop finishe all 20 messages send .But . if we will not use QThread::sleep(1) . then each messages sending individually. why . ?
Is there any way to force send to each messages immediatelly when its published?
:for (int i = 20 ; i < 20 ; i++){ QThread::sleep(1); if(m_client->publish(topic_, QString("testing. . . ").toLocal8Bit() , 1 ,true) == -1; qDebug() << " error" <<; }
-
I would guess that the data is sent asynchronously and since you stop the thread, the eventloop can not do it's job and all is sent after the loop when the eventloop is running again.
Use a QTimer to sent the events so the eventloop is running in between.