Implement initial load through websocket to cut one unnecessary HTTP GET that caused conn pool overflow. Increased reload / retry delays to reduce server spamming by poorly loaded client.

This commit is contained in:
2017-09-08 23:53:23 +02:00
parent a20ec8a49e
commit 1d6d6ee228
2 changed files with 131 additions and 115 deletions
+14 -1
View File
@@ -47,6 +47,7 @@ notifyCooldownTimCb(void *arg)
static void ICACHE_FLASH_ATTR
notifyContentTimCb(void *arg)
{
Websock *ws = arg;
void *data = NULL;
int max_bl, total_bl;
char sock_buff[SOCK_BUF_LEN];
@@ -65,8 +66,14 @@ notifyContentTimCb(void *arg)
int flg = 0;
if (cont == HTTPD_CGI_MORE) flg |= WEBSOCK_FLAG_MORE;
if (i > 0) flg |= WEBSOCK_FLAG_CONT;
cgiWebsockBroadcast(URL_WS_UPDATE, sock_buff, (int) strlen(sock_buff), flg);
if (ws) {
cgiWebsocketSend(ws, sock_buff, (int) strlen(sock_buff), flg);
} else {
cgiWebsockBroadcast(URL_WS_UPDATE, sock_buff, (int) strlen(sock_buff), flg);
}
if (cont == HTTPD_CGI_DONE) break;
system_soft_wdt_feed();
}
// cleanup
@@ -251,6 +258,12 @@ void ICACHE_FLASH_ATTR updateSockRx(Websock *ws, char *data, int len, int flags)
}
break;
case 'i':
// requests initial load
dbg("Client requests initial load");
notifyContentTimCb(ws);
break;
case 'm':
case 'p':
case 'r':