The MQTT messages are delivered asynchronously (“push”) through publish subscribe architecture.
MQTT control packet headers are kept as small as possible.
Three QoS for message delivery could be achieved using MQTT
When a MQTT client connects to the MQTT server it can define a topic and a message that needs to be published automatically on that topic when it unexpectedly disconnects
// Create websocket client and set server options
oClient := TsgcWebSocketClient.Create(nil);
oClient.Host := 'www.esegece.com';
oClient.Port := 15675;
oClient.Options.Parameters := '/ws';
// Create MQTT protocol and assign to websocket client
oMQTT := TsgcWSPClient_MQTT.Create(nil);
oMQTT.Client := oClient;
// MQTT Authentication
oMQTT.Authentication.Enabled := True;
oMQTT.Authentication.Username := 'sgc';
oMQTT.Authentication.Password := 'sgc';
// Handle MQTT methods
oMQTT.OnMQTTConnect := OnMQTTConnectHandler;
oMQTT.OnMQTTDisconnect := OnMQTTDisconnectHandler;
// connect to server
oClient.Active := True;
// Subscribe to channel "myTopic"
oMQTT.Subscribe('myTopic');
// Send a message to all subscribers of channel "myTopic"
oMQTT.Publish('myTopic', 'Text message');
// Send a ping to Server
oMQTT.Ping;
MQTT stands for MQ Telemetry Transport. It is a publish/subscribe, extremely simple and lightweight messaging protocol, designed for constrained devices and low-bandwidth, high-latency or unreliable networks. The design principles are to minimise network bandwidth and device resource requirements whilst also attempting to ensure reliability and some degree of assurance of delivery.