-
public class MqttTopicRepresents a topic destination, used for publish/subscribe messaging.
-
-
Field Summary
Fields Modifier and Type Field Description public final static StringTOPIC_LEVEL_SEPARATORpublic final static StringMULTI_LEVEL_WILDCARDpublic final static StringSINGLE_LEVEL_WILDCARDpublic final static StringMULTI_LEVEL_WILDCARD_PATTERNpublic final static StringSINGLE_LEVEL_WILDCARD_PATTERNpublic final static StringTOPIC_WILDCARDSprivate Stringname
-
Constructor Summary
Constructors Constructor Description MqttTopic(String name, ClientComms comms)
-
Method Summary
Modifier and Type Method Description StringgetName()Returns the name of the queue or topic. MqttDeliveryTokenpublish(Array<byte> payload, int qos, boolean retained)Publishes a message on the topic. MqttDeliveryTokenpublish(MqttMessage message)Publishes the specified message to this topic, but does not wait for delivery of the message to complete. StringtoString()Returns a string representation of this topic. static voidvalidate(String topicString, boolean wildcardAllowed)Validate the topic name or topic filter -
-
Constructor Detail
-
MqttTopic
MqttTopic(String name, ClientComms comms)
-
-
Method Detail
-
publish
MqttDeliveryToken publish(Array<byte> payload, int qos, boolean retained)
Publishes a message on the topic. This is a convenience method, which will create a new MqttMessage object with a byte array payload and the specified QoS, and then publish it. All other values in the message will be set to the defaults.
- Parameters:
payload- the byte array to use as the payloadqos- the Quality of Service.retained- whether or not this message should be retained by the server.
-
publish
MqttDeliveryToken publish(MqttMessage message)
Publishes the specified message to this topic, but does not wait for delivery of the message to complete. The returned token can be used to track the delivery status of the message. Once this method has returned cleanly, the message has been accepted for publication by the client. Message delivery will be completed in the background when a connection is available.
- Parameters:
message- the message to publish
-
-
-
-