Skip to content

TTMSMQTTClient

Constructor

Constructor
Create(AOwner: TComponent)

Properties

Property name Description
Session: TTMSMQTTTMSMQTTClientSession The active MQTT Session
ConnectionStatus: TTMSMQTTConnectionStatus The current status of the client
Connection: TTMSMQTTNetworkConnection The connection with the broker
ConnectionInfo: TTMSMQTTConnectionInfo Connection information sent by the server in the last CONNACK packet.
DisconnectionInfo: TTMSMQTTDisconnectionInfo Disconnection information sent by the server in the last DISCONNECT packet. (MQTT v5+)
ClientID: string A unique client identifier.
BrokerHostName: string Hostname of the broker you want to connect to
BrokerPort: Integer The port to use when connecting to the broker
IPVersion: TIdIPVersion Allows to select between using an IPv4 or IPv6 address
UseSSL: Boolean Whether or not to connect through SSL
ProtocolVersion: TTMSMQTTProtocolVersion MQTT protocol version used in the connection
KeepAliveSettings: TTMSMQTTKeepAliveSettings Setting to keep the connection alive
Credentials: TTMSMQTTCredentials The credentials to use when connecting
LastWillSettings: TTMSMQTTLastWillSettings The Last Will And Testament (LWT) settings
TimeOutSettings: TTMSMQTTTimeOutSettings Connect & read timeout settings
ConnectionProperties: TTMSMQTTConnectionSettings Connect properties
PublishProperties: TTMSMQTTPublishSettings Publish properties
SubscribeProperties: TTMSMQTTSubscribeSettings Subscribe properties
DisconnectProperties: TTMSMQTTDisconnectSettings Disconnect properties
AutomaticSessionCleanup: Boolean Clear the session automatically.
SyncedEvents: Boolean Trigger the thread events using Synchronize or execute them in the same thread.
Logger: TTMSMQTTLogger The logger to be used by the client
Version: string The Component Version

Methods

Method name Description
Assign(Source: TPersistent)
Connect(ACleanSession: Boolean = True) Connect to the broker
- ACleanSession: Indicates whether the previous session should be cleared.
Disconnect(): Boolean Disconnect from the broker
Subscribe(ATopic: string; ATopicQosLevel: TTMSMQTTQoS = qosAtMostOnce; ARetainHandling: TTMSRetainHandling = rhSendRetainedMessagesAtSubscribe; ARetainAsPublished: Boolean = False; ANoLocal: Boolean = False): Word Subscribe the client to a specific topic
- ATopic: Topic name or filter
- ATopicQosLevel: The "Quality Of Service" the broker should use when sending messages to the client on this topic
- ARetainHandling: This option specifies whether retained messages are sent when the subscription is established. This does not affect the sending of retained messages at any point after the subscribe. If there are no retained messages matching the Topic Filter, all of these values act the same.
- ARetainAsPublished: If True, Application Messages forwarded using this subscription keep the RETAIN flag they were published with. If False, Application Messages forwarded using this subscription have the RETAIN flag set to 0.
- ANoLocal: If True, Application Messages MUST NOT be forwarded to a connection with a ClientID equal to the ClientID of the publishing connection.
Subscribe(ATopics: TTMSStringArray; ATopicQosLevels: TTMSQosArray; ARetainHandlingValues: TTMSRetainHandlingArray; ARetainAsPublishedValues: TTMSBooleanArray; ANoLocalValues: TTMSBooleanArray): Word Subscribe the client to a multiple topics
- ATopics: Names/filters of the Topics
- ATopicQosLevels: Set of "Quality Of Service" settings that the broker should use when sending messages to the client
- ARetainHandlingValues: Set of "Retain Handling" values. This option specifies whether retained messages are sent when the subscription is established. This does not affect the sending of retained messages at any point after the subscribe. If there are no retained messages matching the Topic Filter, all of these values act the same.
- ARetainAsPublishedValues: Set of "Retain as Published". If True, Application Messages forwarded using this subscription keep the RETAIN flag they were published with. If False, Application Messages forwarded using this subscription have the RETAIN flag set to 0.
- ANoLocalValues: Set of "No Local". If True, Application Messages MUST NOT be forwarded to a connection with a ClientID equal to the ClientID of the publishing connection.
Subscribe(ATopics: TTMSStringArray; ATopicQosLevels: TTMSQosArray): Word Subscribe the client to a multiple topics
- ATopics: Names/filters of the Topics
- ATopicQosLevels: Set of "Quality Of Service" settings that the broker should use when sending messages to the client
Subscribe(ATopics: TTMSStringArray; ATopicQosLevels: TTMSQosArray; APacketID: Word): Boolean Subscribe the client to a multiple topics
- ATopics: Names/filters of the Topics
- ATopicQosLevels: Set of "Quality Of Service" settings that the broker should use when sending messages to the client
- APacketID: Packet identifier used by the SUBSCRIBE control packet.
Subscribe(ATopics: TTMSStringArray; ATopicQosLevels: TTMSQosArray; ARetainHandlingValues: TTMSRetainHandlingArray; ARetainAsPublishedValues: TTMSBooleanArray; ANoLocalValues: TTMSBooleanArray; APacketID: Word): Boolean Subscribe the client to a multiple topics
- ATopics: Names/filters of the Topics
- ATopicQosLevels: Set of "Quality Of Service" settings that the broker should use when sending messages to the client
- ARetainHandlingValues: Set of "Retain Handling" values. This option specifies whether retained messages are sent when the subscription is established. This does not affect the sending of retained messages at any point after the subscribe. If there are no retained messages matching the Topic Filter, all of these values act the same.
- ARetainAsPublishedValues: Set of "Retain as Published". If True, Application Messages forwarded using this subscription keep the RETAIN flag they were published with. If False, Application Messages forwarded using this subscription have the RETAIN flag set to 0.
- ANoLocalValues: Set of "No Local". If True, Application Messages MUST NOT be forwarded to a connection with a ClientID equal to the ClientID of the publishing connection.
- APacketID: Packet identifier used by the SUBSCRIBE control packet.
Unsubscribe(ATopic: string): Word Unsubscribe from a specific topic
- ATopic: Topic name or filter
Unsubscribe(ATopics: TTMSStringArray): Word Unsubscribe from multiple topics at once
- ATopics: Names/filters of the Topics
Unsubscribe(ATopic: string; APacketID: Word): Boolean Unsubscribe from a specific topic
- ATopic: Topic name or filter
- APacketID: Packet identifier used by the UNSUBSCRIBE control packet.
Unsubscribe(ATopics: TTMSStringArray; APacketID: Word): Boolean Unsubscribe from multiple topics at once
- ATopics: Names/filters of the Topics
- APacketID: Packet identifier used by the UNSUBSCRIBE control packet.
Ping Send a PING packet to the broker
Publish(ATopic: string; APayload: string; AQos: TTMSMQTTQoS = qosAtMostOnce; ARetain: Boolean = False; ADuplicate: Boolean = False): Word Publish a string message to a specific topic on the broker.
- ATopic: Topic name
- APayload: The content of the packet
- AQos: The "Quality Of Service" the client should use when sending the packet to the broker (default = qosAtMostOnce)
- ARetain: Whether or not the message should be retained by the broker (default is false)
- ADuplicate: Indicates that this is the first occasion that the Client or Server has attempted to send this PUBLISH packet. (default is false)
Publish(ATopic: string; APayload: TBytes; AQos: TTMSMQTTQoS = qosAtMostOnce; ARetain: Boolean = False; ADuplicate: Boolean = False): Word Publish a binary message to a specific topic on the broker.
- ATopic: Topic name
- APayload: The content of the packet
- AQos: The "Quality Of Service" the client should use when sending the packet to the broker (default = qosAtMostOnce)
- ARetain: Whether or not the message should be retained by the broker (default is false)
- ADuplicate: Indicates that this is the first occasion that the Client or Server has attempted to send this PUBLISH packet. (default is false)
Publish(ATopic: string; APayload: string; APacketID: Word; AQos: TTMSMQTTQoS = qosAtMostOnce; ARetain: Boolean = False; ADuplicate: Boolean = False): Boolean Publish a string message to a specific topic on the broker.
- ATopic: Topic name
- APayload: The content of the packet
- APacketID: Packet identifier used by the PUBLISH control packet.
- AQos: The "Quality Of Service" the client should use when sending the packet to the broker (default = qosAtMostOnce)
- ARetain: Whether or not the message should be retained by the broker (default is false)
- ADuplicate: Indicates that this is the first occasion that the Client or Server has attempted to send this PUBLISH packet. (default is false)
Publish(ATopic: string; APayload: TBytes; APacketID: Word; AQos: TTMSMQTTQoS = qosAtMostOnce; ARetain: Boolean = False; ADuplicate: Boolean = False): Boolean Publish a binary message to a specific topic on the broker.
- ATopic: Topic name
- APayload: The content of the packet
- APacketID: Packet identifier used by the PUBLISH control packet.
- AQos: The "Quality Of Service" the client should use when sending the packet to the broker (default = qosAtMostOnce)
- ARetain: Whether or not the message should be retained by the broker (default is false)
- ADuplicate: Indicates that this is the first occasion that the Client or Server has attempted to send this PUBLISH packet. (default is false)
IsConnected(): Boolean Whether the client is connected to a broker or not
Authenticate(AAuthenticationMethod: string; AAuthenticationData: TBytes; AReauthenticate: Boolean = False): Boolean Send an AUTH packet to the SErver as part of an extended authentication exchange.
- AAuthenticationMethod: String containing the name of the authentication method.
- AAuthenticationData: Binary Data containing authentication data. The contents of this data are defined by the authentication method.
- AReauthenticate: Set to True if the client needs to initiate a re-authentication. Set to False if the client continues authenticating.

Events

Event name Description
OnConnectedStatusChanged Event triggered when the status of the client changes
OnPacketReceived Event triggered when a packet is received from the broker
OnPacketSent Event triggered when a packet is sent to the broker
OnRawPacketReceived Event triggered after a packet is received from the broker
OnRawPacketSent Event triggered before a packet is sent to the broker
OnServerRedirection Event triggered when the Server requests that the Client uses another Server in the CONNACK or DISCONNECT packets.
OnAuthReceived Event triggered when an AUTH packet is received.
OnOutgoingPacketTooBig Event triggered when a packet exceedes the maximum packet size.
OnPingRequest Event triggered when the client receives a ping request (PINGREQ) packet from the broker
OnPingResponse Event triggered when the client receives a ping response (PINGRES) packet from the broker
OnPublishReceived Event triggered when the client receives a PUBLISH packet from the broker
OnPublishReceivedEx Event triggered when the client receives a PUBLISH packet from the broker
This event is a copy of the 'OnPublishReceived' event and added for compatibility with C++ builder
OnSubscriptionAcknowledged Event triggered when the client recieves a SUBACK packet from the broker
OnUnSubscribeAcknowledged Event triggered when the client recieves a UNSUBACK packet from the broker