jishi / node-sonos-http-api

An HTTP API bridge for Sonos easing automation. Hostable on any node.js capable device, like a raspberry pi or similar.
http://jishi.github.io/node-sonos-http-api/
MIT License
1.84k stars 463 forks source link

Restrict/allow concurrent '...all' actions #743

Open sgraystar opened 4 years ago

sgraystar commented 4 years ago

Concurrent clipall/sayall can leave the system in an undefined state if the second action is processed while the system is in a partially grouped state. An example is clipall/sayall being used with a doorbell and someone pressing the doorbell button twice.

This feature implements a check within all-player-announcements. Calls to the helper will start a timer and, if restricted, subsequent calls will be ignored while the timer is active. This allows time for the original state to be restored before the next clipall/sayall action.

Global variables are possibly not the best implementation, but none of the existing helper files require settings.js so this change did not introduce a require settings.js to all-player-announcements.

The auto changes look larger than actual changes to all-player-announcements, in summary: if NOT (restricted AND current active announcement) { start timer and use timer handle to track an active announcement existing code } function (timer expiry) { null the timer handle }