public class MqttSubscribeSample
extends java.lang.Object
Constructor and Description |
---|
MqttSubscribeSample() |
Modifier and Type | Method and Description |
---|---|
void |
connectionLost(java.lang.Throwable cause) |
void |
deliveryComplete(IMqttDeliveryToken token) |
static void |
main(java.lang.String[] args)
The main entry point of the sample.
|
void |
messageArrived(java.lang.String topic,
MqttMessage message) |
void |
publish(java.lang.String topicName,
int qos,
byte[] payload)
Publish / send a message to an MQTT server
|
void |
subscribe()
Subscribe to a topic on an MQTT server
Once subscribed this method waits for the messages to arrive from the server
that match the subscription.
|
public MqttSubscribeSample() throws MqttException
MqttException
public static void main(java.lang.String[] args)
public void publish(java.lang.String topicName, int qos, byte[] payload) throws MqttException
topicName
- the name of the topic to publish toqos
- the quality of service to delivery the message at (0,1,2)payload
- the set of bytes to send to the MQTT serverMqttException
public void subscribe() throws MqttException
topicName
- to subscribe to (can be wild carded)qos
- the maximum quality of service to receive messages at for this subscriptionMqttException
public void connectionLost(java.lang.Throwable cause)
MqttCallback#connectionLost(Throwable)
public void deliveryComplete(IMqttDeliveryToken token)
MqttCallback#deliveryComplete(IMqttDeliveryToken)
public void messageArrived(java.lang.String topic, MqttMessage message) throws MqttException
MqttException
MqttCallback#messageArrived(String, MqttMessage)