jimmywarting / wemo-client

JavaScript client library for controlling and subscribing to Wemo Devices
MIT License
132 stars 40 forks source link

Remove second call to discover #37

Closed richardwillars closed 8 years ago

richardwillars commented 8 years ago

Don't think this second call to the discover method is necessary.. as I understand it discover takes a callback as a param and that callback is called whenever a new device is discovered. If that's the case you shouldn't call discover twice - it makes this example look like discover ends and isn't continuous

codecov-io commented 8 years ago

Current coverage is 89.88% (diff: 100%)

Merging #37 into master will not change coverage

@@             master        #37   diff @@
==========================================
  Files             2          2          
  Lines           267        267          
  Methods          57         57          
  Messages          0          0          
  Branches         40         40          
==========================================
  Hits            240        240          
  Misses           27         27          
  Partials          0          0          

Powered by Codecov. Last update b5d15c1...f38a60d

timonreinhard commented 8 years ago

The underlying ssdp client sends out a single M-SEARCH request when discover is called. Devices may or may not respond to it. When writing this code (which has been a while ago) I experienced some Wemo devices not responding to the first UPnP request. That is why this example shows how running a continuous discovery could work.

I'll add this to the docs to make it more clear what discover actually does.

danopia commented 8 years ago

I have two devices and a script that only called discover() once. I only got both devices on the fourth try. This is UDP, so delivery isn't even guaranteed

timonreinhard commented 8 years ago

Exactly. I just keep this open until this is added to the docs.

timonreinhard commented 8 years ago

Added some details on how discover works with 6be65fd.