Method DiscoverAsync
- Namespace
- Yeelight
- Assembly
- YeelightClient.dll
DiscoverAsync(TimeSpan, CancellationToken)
Searches for lights for a while, and returns the lights that the client knows then.
public Task<IReadOnlyList<YeelightDevice>> DiscoverAsync(TimeSpan timeout, CancellationToken cancellationToken = default)
Parameters
timeoutTimeSpanHow long to search.
cancellationTokenCancellationTokenTo stop waiting.
Returns
- Task<IReadOnlyList<YeelightDevice>>
The lights that the client knows: the same list as Devices, as it is when the time has passed.
Remarks
When StartDiscovery(TimeSpan?) was called, a search is sent now and the client waits. Otherwise the client searches for the time that it waits, and stops. The lights that are found stay in Devices either way. A light answers a search within a second, but one that does not hear the multicast group (see UseBroadcast) is only found because of the second and the third search, which are a second apart: wait at least three seconds to find all.
Exceptions
- ArgumentOutOfRangeException
The timeout is not more than zero, or more than about 49 days.
- ObjectDisposedException
The client is disposed.
- OperationCanceledException
The wait was cancelled, or the client was disposed while it waited.