TsgcWSPClient_MQTT | Publish and Wait Response

MQTT client allows the use of some type of QoS levels, any of those levels works in a different level to be sure that messages have been processed as expected.

 

There are the following QoS levels:

 

 

You can handle the events OnPubAck or OnPubComp to know if the message has been processed by server or you can use the method PublishAndWait to know if the message has been processed by the server.

The use of PublishAndWait is the same as the normal Publish method, but now you have a new parameter called Timeout, where the method will return false if after a certain period of time, there is no response from server. By default this value is 10 seconds.

 


if mqtt.PublishAndWait('topic', 'text') then
  ShowMessage('Message processed')
else
  ShowMessage('Message error');