MqttConnection Class
- java.
lang. Object - MqttCallback
- com.
microsoft. azure. sdk. iot. provisioning. device. transport. mqtt. MqttConnection
- com.
public class MqttConnection
Constructor Summary
Constructor | Description |
---|---|
MqttConnection(String hostname, String clientId, String userName, String password, SSLContext sslContext, MqttListener listener, boolean useWebSockets) |
Constructor to create MqttAsync Client with Paho |
Method Summary
Modifier and Type | Method and Description |
---|---|
synchronized void |
connect()
Connects to the MQTT broker |
synchronized void |
connectionLost(Throwable throwable)
Event fired when the connection is lost on the MQTT broker |
synchronized void |
deliveryComplete(IMqttDeliveryToken iMqttDeliveryToken)
Event fired when the message arrived on the MQTT broker. |
synchronized void |
disconnect()
Disconnects from the MQTT broker |
String | getConnectionId() |
String | getHostName() |
boolean |
isMqttConnected()
Return whether the MQTT broker is connected to the endpoint |
synchronized void |
messageArrived(String topic, org.eclipse.paho.client.mqttv3.MqttMessage mqttMessage)
Event fired when the message arrived on the MQTT broker. |
synchronized void |
publishMessage(MqttMessage message)
Sends a PUBLISH message to the MQTT broker |
synchronized void |
publishMessage(String topic, MqttQos qos, byte[] message)
Sends a PUBLISH message to the MQTT broker |
synchronized void |
subscribe(String topic, MqttQos qos)
Send the SUBSCRIBE message to the MQTT broker |
synchronized void |
unsubscribe(String topic)
Send the UNSUBSCRIBE message to the MQTT broker |
Constructor Details
MqttConnection
public MqttConnection(String hostname, String clientId, String userName, String password, SSLContext sslContext, MqttListener listener, boolean useWebSockets)
Constructor to create MqttAsync Client with Paho
Parameters:
Throws:
Method Details
connect
public synchronized void connect()
Connects to the MQTT broker
Throws:
connectionLost
public synchronized void connectionLost(Throwable throwable)
Event fired when the connection is lost on the MQTT broker
Parameters:
deliveryComplete
public synchronized void deliveryComplete(IMqttDeliveryToken iMqttDeliveryToken)
Event fired when the message arrived on the MQTT broker.
Parameters:
disconnect
public synchronized void disconnect()
Disconnects from the MQTT broker
Throws:
getConnectionId
public String getConnectionId()
getHostName
public String getHostName()
isMqttConnected
public boolean isMqttConnected()
Return whether the MQTT broker is connected to the endpoint
Returns:
messageArrived
public synchronized void messageArrived(String topic, org.eclipse.paho.client.mqttv3.MqttMessage mqttMessage)
Event fired when the message arrived on the MQTT broker.
Parameters:
publishMessage
public synchronized void publishMessage(MqttMessage message)
Sends a PUBLISH message to the MQTT broker
Parameters:
Throws:
publishMessage
public synchronized void publishMessage(String topic, MqttQos qos, byte[] message)
Sends a PUBLISH message to the MQTT broker
Parameters:
Throws:
subscribe
public synchronized void subscribe(String topic, MqttQos qos)
Send the SUBSCRIBE message to the MQTT broker
Parameters:
Throws:
unsubscribe
public synchronized void unsubscribe(String topic)
Send the UNSUBSCRIBE message to the MQTT broker
Parameters:
Throws:
Applies to
Azure SDK for Java