IotHubTransport Class
- java.
lang. Object - com.
microsoft. azure. sdk. iot. device. transport. IotHubTransport
- com.
Implements
public class IotHubTransport
implements IotHubListener
Manages queueing of message sending, receiving and callbacks. Manages notifying users of connection status change updates
Constructor | Description | |
---|---|---|
Iot |
Constructor for an Iot |
|
Iot |
Modifier and Type | Method and Description |
---|---|
void |
add Adds a message to the transport queue. |
void |
close(Iot Closes all resources used to communicate with an IoT Hub. |
Iot |
get |
java.lang.Object |
get |
java.lang.Object |
get |
void |
handle Invokes the message callback if a message is found and responds to the IoT Hub on how the processed message should be handled by the IoT Hub. |
boolean |
has |
boolean |
has |
boolean |
has |
void |
invoke Invokes the callbacks for all completed requests. |
boolean |
is |
boolean |
is Returns |
void |
on Callback to be fired when the connection has been successfully established |
void |
on Callback to be fired when connection has been lost |
void |
on Callback to be fired when a transport message has been received. |
void |
on Callback to be fired when a message that the transport client sent has been acknowledged by Iot Hub |
void |
on Callback to be fired when the multiplexed connection establishes a new device session. |
void |
on Callback to be fired when the multiplexed connection loses a device session. |
void |
on Callback to be fired when the multiplexed connection fails to register a device session. |
void |
open()
Establishes a communication channel with an IoT Hub. |
void |
register Registers a callback to be executed whenever the connection to the IoT Hub is lost or established. |
void |
register Registers a callback to be executed whenever the connection status to the IoT Hub has changed. |
void |
register |
void |
register |
void |
send Sends all messages on the transport queue. |
void |
set |
void |
unregister |
IotHubTransport
public IotHubTransport(DeviceClientConfig defaultConfig, IotHubConnectionStatusChangeCallback deviceIOConnectionStatusChangeCallback, boolean isMultiplexing)
Constructor for an IotHubTransport object with default values
Parameters:
Throws:
IotHubTransport
public IotHubTransport(String hostName, IotHubClientProtocol protocol, SSLContext sslContext, ProxySettings proxySettings, IotHubConnectionStatusChangeCallback deviceIOConnectionStatusChangeCallback)
Parameters:
Throws:
addMessage
public void addMessage(Message message, IotHubEventCallback callback, Object callbackContext, String deviceId)
Adds a message to the transport queue.
Parameters:
close
public void close(IotHubConnectionStatusChangeReason reason, Throwable cause)
Closes all resources used to communicate with an IoT Hub. Once close()
is called, the transport is no longer usable. If the transport is already closed, the function shall do nothing.
Parameters:
Throws:
getProtocol
public IotHubClientProtocol getProtocol()
getReceiveThreadLock
public Object getReceiveThreadLock()
getSendThreadLock
public Object getSendThreadLock()
handleMessage
public void handleMessage()
Invokes the message callback if a message is found and responds to the IoT Hub on how the processed message should be handled by the IoT Hub.
If no message callback is set, the function will do nothing.
Throws:
hasCallbacksToExecute
public boolean hasCallbacksToExecute()
hasMessagesToSend
public boolean hasMessagesToSend()
hasReceivedMessagesToHandle
public boolean hasReceivedMessagesToHandle()
invokeCallbacks
public void invokeCallbacks()
Invokes the callbacks for all completed requests.
isClosed
public boolean isClosed()
isEmpty
public boolean isEmpty()
Returns true
if the transport has no more messages to handle, and false
otherwise.
Returns:
true
if the transport has no more messages to handle,
and false
otherwise.onConnectionEstablished
public void onConnectionEstablished(String connectionId)
Callback to be fired when the connection has been successfully established
Parameters:
onConnectionLost
public void onConnectionLost(Throwable e, String connectionId)
Callback to be fired when connection has been lost
Parameters:
onMessageReceived
public void onMessageReceived(IotHubTransportMessage message, Throwable e)
Callback to be fired when a transport message has been received.
Parameters:
onMessageSent
public void onMessageSent(Message message, String deviceId, Throwable e)
Callback to be fired when a message that the transport client sent has been acknowledged by Iot Hub
Parameters:
onMultiplexedDeviceSessionEstablished
public void onMultiplexedDeviceSessionEstablished(String connectionId, String deviceId)
Callback to be fired when the multiplexed connection establishes a new device session.
Parameters:
onMultiplexedDeviceSessionLost
public void onMultiplexedDeviceSessionLost(Throwable e, String connectionId, String deviceId)
Callback to be fired when the multiplexed connection loses a device session.
Parameters:
onMultiplexedDeviceSessionRegistrationFailed
public void onMultiplexedDeviceSessionRegistrationFailed(String connectionId, String deviceId, Exception e)
Callback to be fired when the multiplexed connection fails to register a device session.
Parameters:
open
public void open()
Establishes a communication channel with an IoT Hub. If a channel is already open, the function shall do nothing.
If reconnection is occurring when this is called, this function shall block and wait for the reconnection to finish before trying to open the connection
Throws:
registerConnectionStateCallback
public void registerConnectionStateCallback(IotHubConnectionStateCallback callback, Object callbackContext)
Registers a callback to be executed whenever the connection to the IoT Hub is lost or established.
Parameters:
null
if no callback is provided.
registerConnectionStatusChangeCallback
public void registerConnectionStatusChangeCallback(IotHubConnectionStatusChangeCallback callback, Object callbackContext, String deviceId)
Registers a callback to be executed whenever the connection status to the IoT Hub has changed.
Parameters:
null
.
registerMultiplexedDeviceClient
public void registerMultiplexedDeviceClient(List
Parameters:
Throws:
registerMultiplexingConnectionStateCallback
public void registerMultiplexingConnectionStateCallback(IotHubConnectionStatusChangeCallback callback, Object callbackContext)
Parameters:
sendMessages
public void sendMessages()
Sends all messages on the transport queue. If a previous send attempt had failed, the function will attempt to resend the messages in the previous attempt.
setMultiplexingRetryPolicy
public void setMultiplexingRetryPolicy(RetryPolicy retryPolicy)
Parameters:
unregisterMultiplexedDeviceClient
public void unregisterMultiplexedDeviceClient(List
Parameters:
Throws:
Azure SDK for Java-feedback
Azure SDK for Java is een open source project. Selecteer een koppeling om feedback te geven: