Merge pull request #17 from ahinrichs/pr-rate-limit-ws-cleanup
[WebApi] rate limit ws cleanup (1/s)
This commit is contained in:
commit
39e6a46665
@ -31,6 +31,7 @@ private:
|
|||||||
WebApiSysstatusClass _webApiSysstatus;
|
WebApiSysstatusClass _webApiSysstatus;
|
||||||
WebApiWebappClass _webApiWebapp;
|
WebApiWebappClass _webApiWebapp;
|
||||||
WebApiWsLiveClass _webApiWsLive;
|
WebApiWsLiveClass _webApiWsLive;
|
||||||
|
unsigned long lastTimerCall = 0;
|
||||||
|
|
||||||
void onWebsocketEvent(AsyncWebSocket* server, AsyncWebSocketClient* client, AwsEventType type, void* arg, uint8_t* data, size_t len);
|
void onWebsocketEvent(AsyncWebSocket* server, AsyncWebSocketClient* client, AwsEventType type, void* arg, uint8_t* data, size_t len);
|
||||||
};
|
};
|
||||||
|
|||||||
@ -47,7 +47,10 @@ void WebApiClass::loop()
|
|||||||
_webApiWsLive.loop();
|
_webApiWsLive.loop();
|
||||||
|
|
||||||
// see: https://github.com/me-no-dev/ESPAsyncWebServer#limiting-the-number-of-web-socket-clients
|
// see: https://github.com/me-no-dev/ESPAsyncWebServer#limiting-the-number-of-web-socket-clients
|
||||||
_ws.cleanupClients();
|
if (millis() - lastTimerCall > 1000) {
|
||||||
|
_ws.cleanupClients();
|
||||||
|
lastTimerCall = millis();
|
||||||
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
void WebApiClass::onWebsocketEvent(AsyncWebSocket* server, AsyncWebSocketClient* client, AwsEventType type, void* arg, uint8_t* data, size_t len)
|
void WebApiClass::onWebsocketEvent(AsyncWebSocket* server, AsyncWebSocketClient* client, AwsEventType type, void* arg, uint8_t* data, size_t len)
|
||||||
|
|||||||
Loading…
Reference in New Issue
Block a user