MqttIotHubConnection Class
- java.
lang. Object - IotHubTransportConnection
- com.
microsoft. azure. sdk. iot. device. transport. mqtt. MqttIotHubConnection
- com.
public class MqttIotHubConnection implements IotHubTransportConnection
Constructor Summary
Constructor | Description |
---|---|
MqttIotHubConnection(ClientConfiguration config) |
Constructs an instance from the given ClientConfiguration object. |
Method Summary
Modifier and Type | Method and Description |
---|---|
void |
close()
Closes the connection. After the connection is closed, it is no longer usable. If the connection is already closed, the function shall do nothing. |
String |
getConnectionId()
Gives the UUID associated with this connection instance. This string is used in conjunction with the callbacks with connection status updates to ensure that all connection status updates are relevant to this connection object |
void | onMessageArrived(int messageId) |
void |
open()
Establishes a connection for the device and IoT Hub given in the client configuration. If the connection is already open, the function shall do nothing. |
Iot |
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. This listener updates the Transport layer of connection status updates, message arrivals, and message acknowledgements |
Constructor Details
MqttIotHubConnection
public MqttIotHubConnection(ClientConfiguration config)
Constructs an instance from the given ClientConfiguration object.
Parameters:
Throws:
Method Details
close
public void close()
Closes the connection. After the connection is closed, it is no longer usable. If the connection is already closed, the function shall do nothing.
Overrides:
MqttIotHubConnection.close()getConnectionId
public String getConnectionId()
Gives the UUID associated with this connection instance. This string is used in conjunction with the callbacks with connection status updates to ensure that all connection status updates are relevant to this connection object
Overrides:
MqttIotHubConnection.getConnectionId()Returns:
onMessageArrived
public void onMessageArrived(int messageId)
Parameters:
open
public void open()
Establishes a connection for the device and IoT Hub given in the client configuration. If the connection is already open, the function shall do nothing.
Overrides:
MqttIotHubConnection.open()Throws:
sendMessage
public IotHubStatusCode sendMessage(Message message)
Sends an event message.
Overrides:
MqttIotHubConnection.sendMessage(Message message)Parameters:
Returns:
Throws:
sendMessageResult
public boolean sendMessageResult(IotHubTransportMessage message, IotHubMessageResult result)
Sends an ACK to the service for the provided message
Overrides:
MqttIotHubConnection.sendMessageResult(IotHubTransportMessage message, IotHubMessageResult result)Parameters:
Returns:
Throws:
setListener
public void setListener(IotHubListener listener)
Sets a listener into the Transport Connection object. This listener updates the Transport layer of connection status updates, message arrivals, and message acknowledgements
Overrides:
MqttIotHubConnection.setListener(IotHubListener listener)Parameters:
Applies to
Azure SDK for Java