你当前正在访问 Microsoft Azure Global Edition 技术文档网站。 如果需要访问由世纪互联运营的 Microsoft Azure 中国技术文档网站,请访问 https://docs.azure.cn。
DeviceIO Class
- java.
lang. Object - com.
microsoft. azure. sdk. iot. device. DeviceIO
- com.
Implements
public final class DeviceIO
implements IotHubConnectionStatusChangeCallback
The task scheduler for sending and receiving messages for the Device Client
Method Summary
Modifier and Type | Method and Description |
---|---|
void |
close()
Completes all current outstanding requests and closes the IoT Hub client. |
void | closeWithoutWrappingException() |
void |
execute(IotHubConnectionStatus status, IotHubConnectionStatusChangeReason statusChangeReason, Throwable throwable, Object callbackContext)
Callback that is executed when the connection status of this sdk to the iot hub changes. |
Iot |
getProtocol()
Getter for the transport protocol. |
long |
getReceivePeriodInMilliseconds()
Getter for the receive period in milliseconds. |
long |
getSendPeriodInMilliseconds()
Getter for the send period in milliseconds. |
boolean |
isEmpty()
Getter for the transport empty queue. |
boolean |
isOpen()
Getter for the connection state. |
void |
registerConnectionStateCallback(IotHubConnectionStateCallback callback, Object callbackContext)
Registers a callback with the configured transport to be executed whenever the connection to the device is lost or established. |
synchronized void |
sendEventAsync(Message message, IotHubEventCallback callback, Object callbackContext, String deviceId)
Asynchronously sends an event message to the IoT Hub. |
void |
setReceivePeriodInMilliseconds(long newIntervalInMilliseconds)
Setter for the receive period in milliseconds. |
void |
setSendPeriodInMilliseconds(long newIntervalInMilliseconds)
Setter for the send period in milliseconds. |
Methods inherited from java.lang.Object
Method Details
close
public void close()
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 close()
is called, the IoT Hub client is no longer usable. If the client is already closed, the function shall do nothing.
Throws:
closeWithoutWrappingException
execute
public void execute(IotHubConnectionStatus status, IotHubConnectionStatusChangeReason statusChangeReason, Throwable throwable, Object callbackContext)
Callback that is executed when the connection status of this sdk to the iot hub changes. Includes details for more context on why that change occurred.
Parameters:
getProtocol
public IotHubClientProtocol getProtocol()
Getter for the transport protocol.
Returns:
getReceivePeriodInMilliseconds
public long getReceivePeriodInMilliseconds()
Getter for the receive period in milliseconds.
Returns:
getSendPeriodInMilliseconds
public long getSendPeriodInMilliseconds()
Getter for the send period in milliseconds.
Returns:
isEmpty
public boolean isEmpty()
Getter for the transport empty queue.
Returns:
isOpen
public boolean isOpen()
Getter for the connection state.
Returns:
registerConnectionStateCallback
public void registerConnectionStateCallback(IotHubConnectionStateCallback callback, Object callbackContext)
Registers a callback with the configured transport to be executed whenever the connection to the device is lost or established.
Parameters:
null
if no callback is provided.
sendEventAsync
public synchronized void sendEventAsync(Message message, IotHubEventCallback callback, Object callbackContext, String deviceId)
Asynchronously sends an event message to the IoT Hub.
Parameters:
null
.
null
if no callback is provided.
setReceivePeriodInMilliseconds
public void setReceivePeriodInMilliseconds(long newIntervalInMilliseconds)
Setter for the receive period in milliseconds.
Parameters:
Throws:
setSendPeriodInMilliseconds
public void setSendPeriodInMilliseconds(long newIntervalInMilliseconds)
Setter for the send period in milliseconds.
Parameters:
Throws: