Browse Source

WebUI: alert when WS closes (#2131)

* Added alert when websocket closes and trying to trigger it faster

* Added window before function...

* Changed from setTimeout to SetInterval

* Fixed position of if statement

* formatting

* images

Co-authored-by: Max Prokhorov <prokhorov.max@outlook.com>
mcspr-patch-1
foxman69 4 years ago
committed by GitHub
parent
commit
bc1fb0ba38
18 changed files with 17807 additions and 17748 deletions
  1. BIN
      code/espurna/data/index.all.html.gz
  2. BIN
      code/espurna/data/index.light.html.gz
  3. BIN
      code/espurna/data/index.lightfox.html.gz
  4. BIN
      code/espurna/data/index.rfbridge.html.gz
  5. BIN
      code/espurna/data/index.rfm69.html.gz
  6. BIN
      code/espurna/data/index.sensor.html.gz
  7. BIN
      code/espurna/data/index.small.html.gz
  8. BIN
      code/espurna/data/index.thermostat.html.gz
  9. +2102
    -2096
      code/espurna/static/index.all.html.gz.h
  10. +2046
    -2041
      code/espurna/static/index.light.html.gz.h
  11. +2354
    -2349
      code/espurna/static/index.lightfox.html.gz.h
  12. +2450
    -2445
      code/espurna/static/index.rfbridge.html.gz.h
  13. +2949
    -2943
      code/espurna/static/index.rfm69.html.gz.h
  14. +1801
    -1795
      code/espurna/static/index.sensor.html.gz.h
  15. +2385
    -2380
      code/espurna/static/index.small.html.gz.h
  16. +1704
    -1699
      code/espurna/static/index.thermostat.html.gz.h
  17. +5
    -0
      code/espurna/ws.ino
  18. +11
    -0
      code/html/custom.js

BIN
code/espurna/data/index.all.html.gz View File


BIN
code/espurna/data/index.light.html.gz View File


BIN
code/espurna/data/index.lightfox.html.gz View File


BIN
code/espurna/data/index.rfbridge.html.gz View File


BIN
code/espurna/data/index.rfm69.html.gz View File


BIN
code/espurna/data/index.sensor.html.gz View File


BIN
code/espurna/data/index.small.html.gz View File


BIN
code/espurna/data/index.thermostat.html.gz View File


+ 2102
- 2096
code/espurna/static/index.all.html.gz.h
File diff suppressed because it is too large
View File


+ 2046
- 2041
code/espurna/static/index.light.html.gz.h
File diff suppressed because it is too large
View File


+ 2354
- 2349
code/espurna/static/index.lightfox.html.gz.h
File diff suppressed because it is too large
View File


+ 2450
- 2445
code/espurna/static/index.rfbridge.html.gz.h
File diff suppressed because it is too large
View File


+ 2949
- 2943
code/espurna/static/index.rfm69.html.gz.h
File diff suppressed because it is too large
View File


+ 1801
- 1795
code/espurna/static/index.sensor.html.gz.h
File diff suppressed because it is too large
View File


+ 2385
- 2380
code/espurna/static/index.small.html.gz.h
File diff suppressed because it is too large
View File


+ 1704
- 1699
code/espurna/static/index.thermostat.html.gz.h
File diff suppressed because it is too large
View File


+ 5
- 0
code/espurna/ws.ino View File

@ -231,6 +231,11 @@ void _wsParse(AsyncWebSocketClient *client, uint8_t * payload, size_t length) {
const char* action = root["action"];
if (action) {
if (strcmp(action, "ping") == 0) {
wsSend_P(client_id, PSTR("{\"pong\": 1}"));
return;
}
DEBUG_MSG_P(PSTR("[WEBSOCKET] Requested action: %s\n"), action);
if (strcmp(action, "reboot") == 0) {


+ 11
- 0
code/html/custom.js View File

@ -12,6 +12,7 @@ var numReboot = 0;
var numReconnect = 0;
var numReload = 0;
var configurationSaved = false;
var ws_pingpong;
var useWhite = false;
var useCCT = false;
@ -2136,6 +2137,16 @@ function connectToURL(url) {
processData(data);
}
};
websock.onclose = function(evt) {
clearInterval(ws_pingpong);
if (window.confirm("Connection lost with the device, click OK to refresh the page")) {
$("#layout").toggle(false);
window.location.reload();
}
}
websock.onopen = function(evt) {
ws_pingpong = setInterval(function() { sendAction("ping", {}); }, 5000);
}
}).catch(function(error) {
console.log(error);
doReload(5000);


Loading…
Cancel
Save