fixes and tweaks. implemented polling reload on HB loss

This commit is contained in:
2017-09-05 02:13:16 +02:00
parent a82e14961c
commit daba5340f7
5 changed files with 33 additions and 9 deletions
+1 -1
View File
@@ -50,7 +50,7 @@ GLOBAL_CFLAGS = \
-DDEBUG_ANSI=1 \ -DDEBUG_ANSI=1 \
-DDEBUG_ANSI_NOIMPL=1 \ -DDEBUG_ANSI_NOIMPL=1 \
-DHTTPD_MAX_BACKLOG_SIZE=8192 \ -DHTTPD_MAX_BACKLOG_SIZE=8192 \
-DHTTPD_MAX_HEAD_LEN=512 \ -DHTTPD_MAX_HEAD_LEN=1024 \
-DHTTPD_MAX_POST_LEN=512 \ -DHTTPD_MAX_POST_LEN=512 \
-DDEBUG_INPUT=0 \ -DDEBUG_INPUT=0 \
-DDEBUG_HEAP=1 \ -DDEBUG_HEAP=1 \
+15 -3
View File
@@ -1958,6 +1958,7 @@ var Screen = (function () {
var Conn = (function() { var Conn = (function() {
var ws; var ws;
var heartbeatTout; var heartbeatTout;
var pingIv;
function onOpen(evt) { function onOpen(evt) {
console.log("CONNECTED"); console.log("CONNECTED");
@@ -2023,12 +2024,23 @@ var Conn = (function() {
function heartbeat() { function heartbeat() {
clearTimeout(heartbeatTout); clearTimeout(heartbeatTout);
heartbeatTout = setTimeout(heartbeatFail, 3000); heartbeatTout = setTimeout(heartbeatFail, 2000);
} }
function heartbeatFail() { function heartbeatFail() {
console.error("Heartbeat lost, reloading..."); console.error("Heartbeat lost, probing server...");
location.reload(); pingIv = setInterval(function() {
console.log("> ping");
$.get('http://'+_root+'/system/ping', function(resp, status) {
if (status == 200) {
clearInterval(pingIv);
console.info("Server ready, reloading page...");
location.reload();
}
}, {
timeout: 100,
});
}, 500);
} }
return { return {
+15 -3
View File
@@ -392,6 +392,7 @@ var Screen = (function () {
var Conn = (function() { var Conn = (function() {
var ws; var ws;
var heartbeatTout; var heartbeatTout;
var pingIv;
function onOpen(evt) { function onOpen(evt) {
console.log("CONNECTED"); console.log("CONNECTED");
@@ -457,12 +458,23 @@ var Conn = (function() {
function heartbeat() { function heartbeat() {
clearTimeout(heartbeatTout); clearTimeout(heartbeatTout);
heartbeatTout = setTimeout(heartbeatFail, 3000); heartbeatTout = setTimeout(heartbeatFail, 2000);
} }
function heartbeatFail() { function heartbeatFail() {
console.error("Heartbeat lost, reloading..."); console.error("Heartbeat lost, probing server...");
location.reload(); pingIv = setInterval(function() {
console.log("> ping");
$.get('http://'+_root+'/system/ping', function(resp, status) {
if (status == 200) {
clearInterval(pingIv);
console.info("Server ready, reloading page...");
location.reload();
}
}, {
timeout: 100,
});
}, 500);
} }
return { return {
+1 -1
View File
@@ -11,7 +11,7 @@
#define LOOPBACK 0 #define LOOPBACK 0
#define HB_TIME 1500 #define HB_TIME 1000
#define SOCK_BUF_LEN 2000 #define SOCK_BUF_LEN 2000