Class DeviceEndpointClient
- Namespace
- Azure.Iot.Operations.Connector
- Assembly
- Azure.Iot.Operations.Connector.dll
A client for reporting the status of this device and its endpoint
public class DeviceEndpointClient : IDisposable
- Inheritance
-
DeviceEndpointClient
- Implements
- Inherited Members
Methods
Dispose()
Performs application-defined tasks associated with freeing, releasing, or resetting unmanaged resources.
public void Dispose()
GetAndUpdateDeviceStatusAsync(Func<DeviceStatus, DeviceStatus?>, bool, TimeSpan?, CancellationToken)
Get the current status of this device and then optionally update it.
public Task<DeviceStatus> GetAndUpdateDeviceStatusAsync(Func<DeviceStatus, DeviceStatus?> handler, bool onlyIfChanged = false, TimeSpan? commandTimeout = null, CancellationToken cancellationToken = default)
Parameters
handlerFunc<DeviceStatus, DeviceStatus>The function that determines the new device status when given the current device status.
onlyIfChangedboolOnly send the status update if the new status is different from the current status. If the only difference between the current and new status is a 'LastTransitionTime' field, then the statuses will be considered identical.
commandTimeoutTimeSpan?The timeout for each of the 'get' and 'update' commands.
cancellationTokenCancellationTokenCancellation token.
Returns
- Task<DeviceStatus>
The latest device status after this operation.
Remarks
If after retrieving the current status, you don't want to send any updates, handler should return null.
If this happens, this function will return the latest asset status without trying to update it.
This method uses a semaphore to ensure that this same client doesn't accidentally update the device status while
another thread is in the middle of updating the same device. This ensures that the current device status provided in handler
stays accurate while any updating occurs.