nilbus / pinewood-derby

Pinewood derby status board & sensor driver
Other
17 stars 9 forks source link

Speed up button response: get update via ajax response #46

Closed nilbus closed 9 years ago

nilbus commented 9 years ago

Although (on the raspberry pi) ajax requests usually respond in 200ms, button clicks that have an effect on the board take typically 1 second (rarely up to 6) before the board is visually updated. This is because the ajax response doesn't contain the dashboard update. Instead that gets sent via the Faye websocket connection.

In addition to the websocket updates which must still go out to everyone, respond to ajax requests with the dashboard data, and re-render the dashboard using that response.

To prevent multiple yellow flashes, have the JS client cache the most recent response, and only flash and render when subsequent updates differ from the prior.