real-time icons and buttons state

This commit is contained in:
Devaev Maxim
2018-07-17 00:44:38 +03:00
parent caf7f4c99b
commit 514aac8d82
7 changed files with 72 additions and 21 deletions

View File

@@ -13,6 +13,8 @@ var session = new function() {
var __wsOpenHandler = function(event) {
tools.debug("WebSocket opened:", event);
atx.loadInitialState();
msd.loadInitialState();
hid.installCapture(__ws);
__missed_heartbeats = 0;
__ping_timer = setInterval(__pingServer, 1000);
@@ -25,7 +27,11 @@ var session = new function() {
__missed_heartbeats = 0;
} else if (event.msg_type === "event") {
if (event.msg.event === "atx_state") {
atx.setLedsState(event.msg.event_attrs.leds);
atx.setState(event.msg.event_attrs);
// } else if (event.msg.event === "atx_click") {
// atx.setButtonsBusy(event.msg.event_attrs.button);
} else if (event.msg.event === "msd_state") {
msd.setState(event.msg.event_attrs);
}
}
};
@@ -46,7 +52,7 @@ var session = new function() {
__ping_timer = null;
}
hid.clearCapture();
atx.clearLeds();
atx.clearState();
__ws = null;
setTimeout(session.startPoller, 1000);
};