TMQTTClientSubscription

April 3, 2019 ยท View on GitHub

Back to Documentation Index

Represents a client's MQTT subscription. Subscriptions are automatically sent to the server by the TMQTTClient component's InitSession method that fires (if needed) during the Connection process. Duplicate topic filters are allowed. When a message is received by the client, all subscriptions with a matching topic Filter have their HandleMessage method called.

Properties

NameVisibilityAccessDescription
AutoSubscribepublishedRWIf true, the subscription will automatically be sent to the server when the client connects. If false then you must call Subscribe/Unsubscribe manually.
EnabledpublishedRWIs this subscription enabled. Defaults to true. If set to false then the OnMessage event handler won't fire.
FilterpublishedRWThe topic filter as a UTF-8 encoded string. Internally this is parsed and stored as a TMQTTTokenizer object which preforms some basic validation of the text.
QOSpublishedRWIn most cases the server will send messages matching this topic filter using this requested QoS level. Default QoS is QOS1 (qtAT_LEAST_ONCE).
ClientpublishedRWThe MQTTClient object that this subscription is sent over and through which matching messages are received. This property is required or the component will not be able to communicate with the server. When the Client property is changed, it adds/removes the object from the corresponding TMQTTClient.Subscriptions lists.
~~ModifiedpublicRWThis property is set to true whenever any of the properties of the component are changed. Used for updating GUI displays or data stores. Set it to false in code to reset the flag.~~
LastUpdatedpublicROThis is set to the current timestamp whenever a message is received. Used to keep track of how long ago data was received.

Methods

NameVisibilityDescription
CreatepublicCreates the component and sets its default values
DestroypublicDestroys the component and removes it from the Client's Subscriptions list if the Client property has been assigned.
ClearpublicClears the properties of data and resets it to default values. After a call to Clear, the component will be in almost the same state it was as when it was created. The Client property is NOT cleared. The Modified property is set to false.
SubscribepublicSends a SUBSCRIBE packet to the server based on the properties of this object
UnsubscribepublicSends an UNSUBSCRIBE packet to the server based on the properties of this object
~~ChangedprotectedVirtual method that can be overridden. In this class this method calls the OnChanged event handler.~~
AssignpublicAssign the properties and events from another object of class TMQTTClientSubscription

Events

NameDescription
~~OnChangedA TNotifyEvent that is called whenever any of the properties of the component are changed. Intended for notifying GUI displays or data stores about updates.~~
OnMessageThis event is called when the client receives a message matching this subscriptions topic filter. All TMQTTClientSubscription components which match the message will have their OnMessage event handler triggered.
OnSendSubscriptionThis event is called just before this subscription is added to the list of subscriptions the client will be sending to the server. Raise an EAbort exception to cause this subscription to be ignored.