共用方式為


TransportClient Class

  • java.lang.Object
    • com.microsoft.azure.sdk.iot.device.TransportClient


public class TransportClient

Note

This class has been deprecated. This client has been replaced with MultiplexingClient since this client does not support adding or removing devices once the connection has been established. MultiplexingClient allows for adding and removing of devices from multiplexed connections before or after opening the connection.

The public-facing API. Allows user to create a transport client abstracton object to use it for multiple devices to connect to an IoT Hub using the same connection (multiplexing). Handle to register devices to transport client and open / closeNow the connection.

The multiplexed connection is supported with AMQPS / AMQPS_WS protocols.

Field Summary

Modifier and Type Field and Description
static long RECEIVE_PERIOD_MILLIS_AMQPS
static long SEND_PERIOD_MILLIS

Constructor Summary

Constructor Description
TransportClient(IotHubClientProtocol protocol)

Constructor that takes a protocol as an argument.

Method Summary

Modifier and Type Method and Description
void closeNow()

Completes all current outstanding requests and closes the IoT Hub client.

void open()

Creates a deviceIO and sets it to all the device client.

void setRetryPolicy(RetryPolicy retryPolicy)

Sets the given retry policy on the underlying transport Sets the given retry policy on the underlying transport See more details about the default retry policy and about using custom retry policies here

void setSendInterval(long newIntervalInMilliseconds)

Sets the given send interval on the underlying device IO

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

Field Details

RECEIVE_PERIOD_MILLIS_AMQPS

public static long RECEIVE_PERIOD_MILLIS_AMQPS

SEND_PERIOD_MILLIS

public static long SEND_PERIOD_MILLIS

Constructor Details

TransportClient

public TransportClient(IotHubClientProtocol protocol)

Constructor that takes a protocol as an argument.

Parameters:

protocol - the communication protocol used (i.e. AMQPS or AMQPS_WS).

Method Details

closeNow

public void closeNow()

Completes all current outstanding requests and closes the IoT Hub client. Must be called to terminate the background thread that is sending data to IoT Hub. After closeNow() is called, the IoT Hub client is no longer usable. If the client is already closed, the function shall do nothing.

Throws:

java.io.IOException - if the connection to an IoT Hub cannot be closed.

open

public void open()

Creates a deviceIO and sets it to all the device client. Verifies all device client's SAS tokens and renew them if it is necessary. Opens the transport client connection.

Throws:

java.lang.IllegalStateException - if the connection is already open.
java.io.IOException - if the connection is already open.

setRetryPolicy

public void setRetryPolicy(RetryPolicy retryPolicy)

Sets the given retry policy on the underlying transport Sets the given retry policy on the underlying transport See more details about the default retry policy and about using custom retry policies here

Parameters:

retryPolicy - the new interval in milliseconds

setSendInterval

public void setSendInterval(long newIntervalInMilliseconds)

Sets the given send interval on the underlying device IO

Parameters:

newIntervalInMilliseconds - the new interval in milliseconds

Throws:

java.io.IOException - if the given number is less or equal to zero.

Applies to