public class MqttIotHubConnection extends java.lang.Object implements IotHubTransportConnection
| Constructor and Description |
|---|
MqttIotHubConnection(ClientConfiguration config)
Constructs an instance from the given
ClientConfiguration
object. |
| Modifier and Type | Method and Description |
|---|---|
void |
close()
Closes the connection.
|
java.lang.String |
getConnectionId()
Gives the UUID associated with this connection instance.
|
void |
onMessageArrived(int messageId) |
void |
open()
Establishes a connection for the device and IoT Hub given in the client
configuration.
|
IotHubStatusCode |
sendMessage(Message message)
Sends an event message.
|
boolean |
sendMessageResult(IotHubTransportMessage message,
IotHubMessageResult result)
Sends an ACK to the service for the provided message
|
void |
setListener(IotHubListener listener)
Sets a listener into the Transport Connection object.
|
public MqttIotHubConnection(ClientConfiguration config) throws TransportException
ClientConfiguration
object.config - the client configuration.TransportException - if the mqtt connection configuration cannot be constructed.public void open()
throws TransportException
open in interface IotHubTransportConnectionTransportException - if a connection could not to be established.public void close()
close in interface IotHubTransportConnectionpublic void setListener(IotHubListener listener) throws java.lang.IllegalArgumentException
IotHubTransportConnectionsetListener in interface IotHubTransportConnectionlistener - the listener for connection status updates, message arrivals, and message acknowledgementsjava.lang.IllegalArgumentExceptionpublic IotHubStatusCode sendMessage(Message message) throws TransportException
sendMessage in interface IotHubTransportConnectionmessage - the event message.TransportException - if the MqttIotHubConnection is not openpublic boolean sendMessageResult(IotHubTransportMessage message, IotHubMessageResult result) throws TransportException
sendMessageResult in interface IotHubTransportConnectionmessage - the message to acknowledge to the serviceresult - Ignored. The only ack that can be sent in MQTT is COMPLETETransportException - if the ACK could not be sent successfullypublic java.lang.String getConnectionId()
IotHubTransportConnectiongetConnectionId in interface IotHubTransportConnectionpublic void onMessageArrived(int messageId)
Copyright © 2023. All rights reserved.