HttpsIotHubConnection Class

  • java.lang.Object
    • com.microsoft.azure.sdk.iot.device.transport.https.HttpsIotHubConnection

Implements

public class HttpsIotHubConnection
implements IotHubTransportConnection

An HTTPS connection between a device and an IoT Hub. Contains functionality for synchronously connecting to the different IoT Hub resource URIs.

Constructor Summary

Constructor Description
HttpsIotHubConnection(DeviceClientConfig config)

Constructs an instance from the given DeviceClientConfig object.

Method Summary

Modifier and Type Method and Description
void close()

Closes the transport connection.

java.lang.String getConnectionId()

Gives the UUID associated with this connection instance.

void open()

Opens the transport connection object

IotHubTransportMessage receiveMessage()

Receives an IotHubTransportMessage, if one exists.

ResponseMessage sendHttpsMessage(HttpsMessage httpsMessage, HttpsMethod httpsMethod, String httpsPath, Map<String,String> additionalHeaders)

Sends an generic https message.

IotHubStatusCode sendMessage(Message message)

Sends an event message.

boolean sendMessageResult(IotHubTransportMessage message, IotHubMessageResult result)

Sends the message result for the previously received message.

void setListener(IotHubListener listener)

Sets a listener into the Transport Connection object.

Methods inherited from java.lang.Object

java.lang.Object.clone java.lang.Object.equals java.lang.Object.finalize java.lang.Object.getClass java.lang.Object.hashCode java.lang.Object.notify java.lang.Object.notifyAll java.lang.Object.toString java.lang.Object.wait java.lang.Object.wait java.lang.Object.wait

Constructor Details

HttpsIotHubConnection

public HttpsIotHubConnection(DeviceClientConfig config)

Constructs an instance from the given DeviceClientConfig object.

Parameters:

config - the client configuration.

Method Details

close

public void close()

Closes the transport connection.

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

open

public void open()

Opens the transport connection object

receiveMessage

public IotHubTransportMessage receiveMessage()

Receives an IotHubTransportMessage, if one exists.

Returns:

an IotHubTransportMessage, or null if none exists.

Throws:

TransportException - if the IoT Hub could not be reached.

sendHttpsMessage

public ResponseMessage sendHttpsMessage(HttpsMessage httpsMessage, HttpsMethod httpsMethod, String httpsPath, Map additionalHeaders)

Sends an generic https message.

Parameters:

httpsMessage - the message to send.
httpsMethod - the https method (GET, POST, PUT, DELETE).
httpsPath - the path that will be added at the end of the URI with /.
additionalHeaders - any extra headers to be included in the http request

Returns:

the ResponseMessage including status code and payload from sending message.

Throws:

TransportException - if the IoT Hub could not be reached.

sendMessage

public IotHubStatusCode sendMessage(Message message)

Sends an event message.

Parameters:

message - the event message.

Returns:

the IotHubStatusCode from sending the event message.

Throws:

TransportException - if the IoT Hub could not be reached.

sendMessageResult

public boolean sendMessageResult(IotHubTransportMessage message, IotHubMessageResult result)

Sends the message result for the previously received message.

Parameters:

message - the message that was received from the service to send the result of
result - the message result (one of COMPLETE, ABANDON, or REJECT).

Throws:

TransportException - if sendMessageResult is called before #receiveMessage() is called.

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

Parameters:

listener

Applies to