InternalClient Class
- java.
lang. Object - com.
microsoft. azure. sdk. iot. device. InternalClient
- com.
public class InternalClient
Field Summary
Modifier and Type | Field and Description |
---|---|
final int | DEFAULT_TIMEOUT_MILLISECONDS |
Method Summary
Modifier and Type | Method and Description |
---|---|
void |
close()
Close the client. |
Client |
getConfig()
Getter for the device client config. |
Product |
getProductInfo() |
Twin |
getTwin()
Get the twin for this client. This client must have subscribed to desired properties before this method can be called. |
Twin |
getTwin(int timeoutMilliseconds)
Get the twin for this client. This client must have subscribed to desired properties before this method can be called. |
void |
getTwinAsync(GetTwinCallback twinCallback, Object callbackContext)
Get the twin for this client asynchronously. This client must have subscribed to desired properties before this method can be called. |
void |
getTwinAsync(GetTwinCorrelatingMessageCallback twinCallback, Object callbackContext)
Get the twin for this client asynchronously. This client must have subscribed to desired properties before this method can be called. This overload utilizes a more verbose callback than getTwinAsync(GetTwinCallback twinCallback, Object callbackContext) and is only intended for users who need insight on the state of this process every step of the way. |
void |
open(boolean withRetry)
Starts asynchronously sending and receiving messages from an IoT hub. If the client is already open, the function shall do nothing. |
void |
sendEvent(Message message)
Synchronously sends a message to IoT hub. |
void |
sendEvent(Message message, int timeoutMilliseconds)
Synchronously sends a message to IoT hub. |
void |
sendEventAsync(Message message, MessageSentCallback callback, Object callbackContext)
Asynchronously sends a message to IoT hub. |
void |
sendEvents(List<Message> messages)
Synchronously sends a batch of messages to IoT hub This operation is only supported over HTTPS. Maximum payload size for HTTPS is 255KB |
void |
sendEvents(List<Message> messages, int timeoutMilliseconds)
Synchronously sends a batch of messages to IoT hub This operation is only supported over HTTPS. Maximum payload size for HTTPS is 255KB |
void |
sendEventsAsync(List<Message> messages, MessagesSentCallback callback, Object callbackContext)
Asynchronously sends a batch of messages to the IoT hub This operation is only supported over HTTPS. This API call is an all-or-nothing single HTTPS message and the callback will be triggered once this batch message has been sent. Maximum payload size for HTTPS is 255KB |
void |
setConnectionStatusChangeCallback(IotHubConnectionStatusChangeCallback callback, Object callbackContext)
Sets the callback to be executed when the connection status of the device changes. The callback will be fired with a status and a reason why the device's status changed. When the callback is fired, the provided context will be provided alongside the status and reason. This connection status callback is not triggered by any upstream connection change events. For example, if if the connection status callback is set for a module on an IoT Edge device and that IoT Edge device loses connection to the cloud, this connection status callback won't onStatusChanged since the connection between the module and the IoT Edge device hasn't changed. Note that the thread used to deliver this callback should not be used to call open()/closeNow() on the client that this callback belongs to. All open()/close() operations should be done on a separate thread |
void |
setOperationTimeout(long timeout)
Set the length of time, in milliseconds, that any given operation will expire in. These operations include reconnecting upon a connection drop and sending a message. |
void |
setRetryPolicy(RetryPolicy retryPolicy)
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 |
subscribeToDesiredProperties(DesiredPropertiesCallback desiredPropertiesCallback, Object desiredPropertiesCallbackContext)
Start receiving desired property updates for this client. After subscribing to desired properties, this client can freely send reported property updates and make getTwin calls. |
void |
subscribeToDesiredProperties(DesiredPropertiesCallback desiredPropertiesCallback, Object desiredPropertiesCallbackContext, int timeoutMilliseconds)
Start receiving desired property updates for this client. After subscribing to desired properties, this client can freely send reported property updates and make getTwin calls. |
void |
subscribeToDesiredPropertiesAsync(DesiredPropertiesCallback desiredPropertiesCallback, Object desiredPropertiesCallbackContext, SubscriptionAcknowledgedCallback subscriptionAcknowledgedCallback, Object desiredPropertiesSubscriptionCallbackContext)
Start receiving desired property updates for this client asynchronously. After subscribing to desired properties, this client can freely send reported property updates and make getTwin calls. |
void |
subscribeToMethods(MethodCallback methodCallback, Object methodCallbackContext)
Subscribes to direct methods |
void |
subscribeToMethods(MethodCallback methodCallback, Object methodCallbackContext, int timeoutMilliseconds)
Subscribes to direct methods |
void |
subscribeToMethodsAsync(MethodCallback methodCallback, Object methodCallbackContext, SubscriptionAcknowledgedCallback methodStatusCallback, Object methodStatusCallbackContext)
Subscribes to direct methods |
Reported |
updateReportedProperties(TwinCollection reportedProperties)
Patch this client's twin with the provided reported properties. This client must have subscribed to desired properties before this method can be called. |
Reported |
updateReportedProperties(TwinCollection reportedProperties, int timeoutMilliseconds)
Patch this client's twin with the provided reported properties. This client must have subscribed to desired properties before this method can be called. This client must have subscribed to desired properties before this method can be called. |
void |
updateReportedPropertiesAsync(TwinCollection reportedProperties, ReportedPropertiesCallback reportedPropertiesCallback, Object callbackContext)
Patch this client's twin with the provided reported properties asynchronously. This client must have subscribed to desired properties before this method can be called. |
void |
updateReportedPropertiesAsync(TwinCollection reportedProperties, ReportedPropertiesUpdateCorrelatingMessageCallback reportedPropertiesUpdateCorrelatingMessageCallback, Object callbackContext)
Patch this client's twin with the provided reported properties asynchronously. This client must have subscribed to desired properties before this method can be called. This overload utilizes a more verbose callback than updateReportedPropertiesAsync(TwinCollection reportedProperties, ReportedPropertiesCallback reportedPropertiesCallback, Object callbackContext) and is only intended for users who need insight on the state of this process every step of the way. |
Field Details
DEFAULT_TIMEOUT_MILLISECONDS
protected static final int DEFAULT_TIMEOUT_MILLISECONDS= 60 * 1000
Method Details
close
public void close()
Close the client.
getConfig
public ClientConfiguration getConfig()
Getter for the device client config.
Returns:
getProductInfo
public ProductInfo getProductInfo()
getTwin
public Twin getTwin()
Get the twin for this client. This client must have subscribed to desired properties before this method can be called.
Returns:
Throws:
getTwin
public Twin getTwin(int timeoutMilliseconds)
Get the twin for this client. This client must have subscribed to desired properties before this method can be called.
Parameters:
Returns:
Throws:
getTwinAsync
public void getTwinAsync(GetTwinCallback twinCallback, Object callbackContext)
Get the twin for this client asynchronously. This client must have subscribed to desired properties before this method can be called.
Parameters:
Throws:
getTwinAsync
public void getTwinAsync(GetTwinCorrelatingMessageCallback twinCallback, Object callbackContext)
Get the twin for this client asynchronously. This client must have subscribed to desired properties before this method can be called.
This overload utilizes a more verbose callback than getTwinAsync(GetTwinCallback twinCallback, Object callbackContext) and is only intended for users who need insight on the state of this process every step of the way.
Parameters:
Throws:
open
public void open(boolean withRetry)
Starts asynchronously sending and receiving messages from an IoT hub. If the client is already open, the function shall do nothing.
Parameters:
Throws:
sendEvent
public void sendEvent(Message message)
Synchronously sends a message to IoT hub.
Parameters:
Throws:
sendEvent
public void sendEvent(Message message, int timeoutMilliseconds)
Synchronously sends a message to IoT hub.
Parameters:
Throws:
sendEventAsync
public void sendEventAsync(Message message, MessageSentCallback callback, Object callbackContext)
Asynchronously sends a message to IoT hub.
Parameters:
the callback to be invoked when a response is received. Can benull
</code> . </p>
a context to be passed to the callback. Can be null
</code> if no callback is provided.</p>
Throws:
if the message provided isnull
</code> . </p>
sendEvents
public void sendEvents(List
Synchronously sends a batch of messages to IoT hub
This operation is only supported over HTTPS.
Maximum payload size for HTTPS is 255KB
Parameters:
Throws:
sendEvents
public void sendEvents(List
Synchronously sends a batch of messages to IoT hub
This operation is only supported over HTTPS.
Maximum payload size for HTTPS is 255KB
Parameters:
Throws:
sendEventsAsync
public void sendEventsAsync(List
Asynchronously sends a batch of messages to the IoT hub
This operation is only supported over HTTPS. This API call is an all-or-nothing single HTTPS message and the callback will be triggered once this batch message has been sent.
Maximum payload size for HTTPS is 255KB
Parameters:
the callback to be invoked when a response is received. Can benull
</code> . </p>
a context to be passed to the callback. Can be null
</code> if no callback is provided.</p>
Throws:
if the message provided isnull
</code> . </p>
setConnectionStatusChangeCallback
public void setConnectionStatusChangeCallback(IotHubConnectionStatusChangeCallback callback, Object callbackContext)
Sets the callback to be executed when the connection status of the device changes. The callback will be fired with a status and a reason why the device's status changed. When the callback is fired, the provided context will be provided alongside the status and reason.
This connection status callback is not triggered by any upstream connection change events. For example, if if the connection status callback is set for a module on an IoT Edge device and that IoT Edge device loses connection to the cloud, this connection status callback won't onStatusChanged since the connection between the module and the IoT Edge device hasn't changed.
Note that the thread used to deliver this callback should not be used to call open()/closeNow() on the client that this callback belongs to. All open()/close() operations should be done on a separate thread
Parameters:
a context to be passed to the callback. Can benull
</code> . </p>
setOperationTimeout
public void setOperationTimeout(long timeout)
Set the length of time, in milliseconds, that any given operation will expire in. These operations include reconnecting upon a connection drop and sending a message.
Parameters:
Throws:
setRetryPolicy
public void setRetryPolicy(RetryPolicy retryPolicy)
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:
subscribeToDesiredProperties
public void subscribeToDesiredProperties(DesiredPropertiesCallback desiredPropertiesCallback, Object desiredPropertiesCallbackContext)
Start receiving desired property updates for this client. After subscribing to desired properties, this client can freely send reported property updates and make getTwin calls.
Parameters:
Throws:
subscribeToDesiredProperties
public void subscribeToDesiredProperties(DesiredPropertiesCallback desiredPropertiesCallback, Object desiredPropertiesCallbackContext, int timeoutMilliseconds)
Start receiving desired property updates for this client. After subscribing to desired properties, this client can freely send reported property updates and make getTwin calls.
Parameters:
Throws:
subscribeToDesiredPropertiesAsync
public void subscribeToDesiredPropertiesAsync(DesiredPropertiesCallback desiredPropertiesCallback, Object desiredPropertiesCallbackContext, SubscriptionAcknowledgedCallback subscriptionAcknowledgedCallback, Object desiredPropertiesSubscriptionCallbackContext)
Start receiving desired property updates for this client asynchronously. After subscribing to desired properties, this client can freely send reported property updates and make getTwin calls.
Parameters:
Throws:
subscribeToMethods
public void subscribeToMethods(MethodCallback methodCallback, Object methodCallbackContext)
Subscribes to direct methods
Parameters:
Callback on which direct methods shall be invoked. Cannot benull
</code> . </p>
Context for device method callback. Can benull
</code> .</p>
Throws:
subscribeToMethods
public void subscribeToMethods(MethodCallback methodCallback, Object methodCallbackContext, int timeoutMilliseconds)
Subscribes to direct methods
Parameters:
Callback on which direct methods shall be invoked. Cannot benull
</code> . </p>
Context for device method callback. Can benull
</code> . </p>
Throws:
subscribeToMethodsAsync
public void subscribeToMethodsAsync(MethodCallback methodCallback, Object methodCallbackContext, SubscriptionAcknowledgedCallback methodStatusCallback, Object methodStatusCallbackContext)
Subscribes to direct methods
Parameters:
Callback on which direct methods shall be invoked. Cannot benull
</code> . </p>
Context for device method callback. Can benull
</code> . </p>
Callback for providing IotHub status for direct methods. Cannot benull
</code> . </p>
Context for device method status callback. Can benull
</code> .</p>
Throws:
updateReportedProperties
public ReportedPropertiesUpdateResponse updateReportedProperties(TwinCollection reportedProperties)
Patch this client's twin with the provided reported properties. This client must have subscribed to desired properties before this method can be called.
Parameters:
Returns:
Throws:
updateReportedProperties
public ReportedPropertiesUpdateResponse updateReportedProperties(TwinCollection reportedProperties, int timeoutMilliseconds)
Patch this client's twin with the provided reported properties. This client must have subscribed to desired properties before this method can be called. This client must have subscribed to desired properties before this method can be called.
Parameters:
Returns:
Throws:
updateReportedPropertiesAsync
public void updateReportedPropertiesAsync(TwinCollection reportedProperties, ReportedPropertiesCallback reportedPropertiesCallback, Object callbackContext)
Patch this client's twin with the provided reported properties asynchronously. This client must have subscribed to desired properties before this method can be called.
Parameters:
Throws:
updateReportedPropertiesAsync
public void updateReportedPropertiesAsync(TwinCollection reportedProperties, ReportedPropertiesUpdateCorrelatingMessageCallback reportedPropertiesUpdateCorrelatingMessageCallback, Object callbackContext)
Patch this client's twin with the provided reported properties asynchronously. This client must have subscribed to desired properties before this method can be called.
This overload utilizes a more verbose callback than updateReportedPropertiesAsync(TwinCollection reportedProperties, ReportedPropertiesCallback reportedPropertiesCallback, Object callbackContext) and is only intended for users who need insight on the state of this process every step of the way.
Parameters:
Throws:
Applies to
Azure SDK for Java