Skip to content
This repository has been archived by the owner on Mar 24, 2020. It is now read-only.

No apparent way of synchronising discovery #1

Closed
johncarney opened this issue Mar 18, 2014 · 5 comments
Closed

No apparent way of synchronising discovery #1

johncarney opened this issue Mar 18, 2014 · 5 comments

Comments

@johncarney
Copy link

Discovery appears to be asynchronous, which is fine, but there is no way of determining whether it's finished or not.

Maybe this is intrinsically impossible, but it would be nice if, after calling LFX::Client.discover, we could rely on LFX::Client.lights containing all lights on the network.

@chendo
Copy link
Contributor

chendo commented Mar 18, 2014

There is no way to know the total number of bulbs on the network. The only way the client knows for sure is if it responds to messages. Right now, Client#discover will block until at least one light has been discovered and it has reported its state.

I can make it so that it can wait a bit longer, or you can pass the number of lights, but either of them seem kind of messy..

@johncarney
Copy link
Author

Thought that might be the case. I'd suggest going in the other direction and take out the block altogether. At the moment Client#discover is delivering an illusion of synchronicity.

@chendo
Copy link
Contributor

chendo commented Mar 18, 2014

Thoughts on removing the blocking in Client#discover, but then adding a Client#discover! that takes a timeout and a block. The block is checked every x seconds and if it returns true, it returns. This allows arbitrary conditions like number of devices, device matching light, etc.

@johncarney
Copy link
Author

Works for me 👍

@chendo
Copy link
Contributor

chendo commented Mar 18, 2014

Fixed in e0aac8c

@chendo chendo closed this as completed Mar 18, 2014
Sign up for free to subscribe to this conversation on GitHub. Already have an account? Sign in.
Labels
None yet
Projects
None yet
Development

No branches or pull requests

2 participants