public class MqttIotHubConnection extends Object implements org.eclipse.paho.client.mqttv3.MqttCallback
| Modifier and Type | Field and Description |
|---|---|
protected DeviceClientConfig |
config |
protected Object |
MQTT_CONNECTION_LOCK
The MQTT connection lock.
|
protected State |
state |
| Constructor and Description |
|---|
MqttIotHubConnection(DeviceClientConfig config)
Constructs an instance from the given
DeviceClientConfig
object. |
| Modifier and Type | Method and Description |
|---|---|
void |
close()
Closes the connection.
|
void |
connectionLost(Throwable throwable)
Event fired when the connection with the MQTT broker is lost.
|
void |
deliveryComplete(org.eclipse.paho.client.mqttv3.IMqttDeliveryToken iMqttDeliveryToken) |
void |
messageArrived(String topic,
org.eclipse.paho.client.mqttv3.MqttMessage mqttMessage) |
void |
open()
Establishes a connection for the device and IoT Hub given in the client
configuration.
|
Message |
receiveMessage()
Receives a message, if one exists.
|
IotHubStatusCode |
sendEvent(Message message)
Sends an event message.
|
protected final Object MQTT_CONNECTION_LOCK
protected final DeviceClientConfig config
protected State state
public MqttIotHubConnection(DeviceClientConfig config) throws IllegalArgumentException
DeviceClientConfig
object.config - the client configuration.IllegalArgumentExceptionpublic void open()
throws IOException
IOException - if a connection could not to be established.public void close()
public IotHubStatusCode sendEvent(Message message) throws IllegalStateException
message - the event message.IllegalStateException - if the MqttIotHubConnection is not openpublic Message receiveMessage() throws IllegalStateException
IllegalStateException - if the connection state is currently closed.public void connectionLost(Throwable throwable)
connectionLost in interface org.eclipse.paho.client.mqttv3.MqttCallbackthrowable - Reason for losing the connection.public void messageArrived(String topic, org.eclipse.paho.client.mqttv3.MqttMessage mqttMessage)
messageArrived in interface org.eclipse.paho.client.mqttv3.MqttCallbackpublic void deliveryComplete(org.eclipse.paho.client.mqttv3.IMqttDeliveryToken iMqttDeliveryToken)
deliveryComplete in interface org.eclipse.paho.client.mqttv3.MqttCallbackCopyright © 2017. All rights reserved.