Class DeviceLinkWaiter
Waits on a new device for the approval of a device link that it started, by checking the link's status until it has a sign-in code. The link's Lifetime is counted from when the waiter was created, which doesn't depend on the device's clock.
Namespace: Singulink.Net.Http.Api.Client
Assembly: Singulink.Net.Http.Api.Client.dll
Syntax
public sealed class DeviceLinkWaiter
Remarks
The service decides when the link has expired: a check of a link that is unknown or expired fails with an UnauthorizedApiException with the DeviceLinkExpired error code, which ends the wait. A check that fails for a reason that may not last (see IsTransient(Exception)), such as while the service can't be reached, is made again after the poll interval, until the link's lifetime has passed.
Its members are not thread safe.
Constructors
| Name | Description |
|---|---|
| DeviceLinkWaiter(DeviceLinkStart, TimeProvider?) | Initializes a new instance of the DeviceLinkWaiter class for the specified link, which the link's lifetime is counted from. |
Properties
| Name | Description |
|---|---|
| Link | Gets the link that the waiter waits for, whose Code the new device shows. |
| PollInterval | Gets or sets how long the waiter waits before each check of the link's status. Default is 2 seconds. |
| RemainingLifetime | Gets how much of the link's Lifetime is left, counted from when the waiter was created with the waiter's time provider, or Zero once it has passed. |
Methods
| Name | Description |
|---|---|
| WaitForApprovalAsync(Func<CheckDeviceLinkCommand, CancellationToken, Task<DeviceLinkStatus>>, Action<bool>?, CancellationToken) | Checks the link's status after each poll interval until the link is approved, and returns the sign-in code that the status then has, which the new device redeems with the code verifier that the link was started with. |