MariusRumpf / node-lifx

Node.js implementation of the LIFX LAN protocol :bulb:
MIT License
144 stars 28 forks source link

Add separate message queue for each address (device or broadcast) (base branch es2015) #60

Open ristomatti opened 6 years ago

ristomatti commented 6 years ago

This modifies Client implementation to hold a separate message queue and send timer for each device or multicast address. This should give a noticeable speedup when sending packets to multiple devices.

The LIFX protocol spec defines the maximum message rate which is defined in constants.js as:

MESSAGE_RATE_LIMIT: 50, // in ms

However the number is the maximum rate to send for each device, not the rate of messages in the network. With having a separate message queue for each device we can achieve near immediate response in all lights when multiple lights are addressed at once.

ristomatti commented 6 years ago

@MariusRumpf I tried reaching you through Gitter but since I was not sure if you're following it these days, I decided to push my initial es2015 refactoring branch upstream. This PR is made using it as the base.

I see the CI stuff is failing, probably because the project needs to be built first. I'll see if I can do something about that but as I'm not familiar with any of the CI services I would appreaciate if you could help with this.

codecov-io commented 6 years ago

Codecov Report

Merging #60 into es2015 will increase coverage by 0.33%. The diff coverage is n/a.

Impacted file tree graph

@@            Coverage Diff             @@
##           es2015      #60      +/-   ##
==========================================
+ Coverage   58.41%   58.74%   +0.33%     
==========================================
  Files          50       50              
  Lines        1688     1704      +16     
  Branches      255      259       +4     
==========================================
+ Hits          986     1001      +15     
- Misses        702      703       +1
Impacted Files Coverage Δ
lib/lifx/client.js 89.34% <0%> (+0.25%) :arrow_up:

Continue to review full report at Codecov.

Legend - Click here to learn more Δ = absolute <relative> (impact), ø = not affected, ? = missing data Powered by Codecov. Last update 0468de6...02528d6. Read the comment docs.

ristomatti commented 6 years ago

Ok managed to fix the tests (pushed changes on the base branch). See commits a8f0fc5660a143d233603eb9e29252b7dc8d3847, efba03571eaf86afdcbb0df5bad0eda1238aec4b and 90e907817e3fd637d62637d8d0966d03f4a6a728.