TsgcWSPClient_MQTT | MQTT Subscribe

You can Subscribe to a Topic using method Subscribe from TsgcWSPClient_MQTT. This method has the following parameters:

 

Topic: is the name of the topic to be subscribed.

QoS: one of the 3 QoS levels (not all brokers support all 3 levels). If not specificed uses mtqsAtMostOnce. Read more about QoS Levels.

SubscribeProperties: if MQTT 5.0, are additional properties about subscriptions.

 

 

Subscribe QoS = At Least Once


MQTT.Subscribe('topic1', mtqsAtLeastOnce);

 

Subscribe MQTT 5.0


oProperties := TsgcWSMQTTSubscribe_Properties.Create;
oProperties.SubscriptionIdentifier := 1234;
oProperties.UserProperties.Add('name=value');
 
MQTT.Subscribe('topic1', mtqsAtMostOnce, oProperties);