From cae47a142ab923c06c04690dd05e64d8f7ea01be Mon Sep 17 00:00:00 2001 From: Thomas Basler Date: Wed, 15 Jun 2022 22:53:05 +0200 Subject: [PATCH] Implemented periodic called loop method in webapi --- include/WebApi.h | 1 + src/WebApi.cpp | 6 ++++++ src/main.cpp | 2 ++ 3 files changed, 9 insertions(+) diff --git a/include/WebApi.h b/include/WebApi.h index cf5aa1a..be0b241 100644 --- a/include/WebApi.h +++ b/include/WebApi.h @@ -6,6 +6,7 @@ class WebApiClass { public: WebApiClass(); void init(); + void loop(); private: AsyncWebServer _server; diff --git a/src/WebApi.cpp b/src/WebApi.cpp index 94fcff1..84dc679 100644 --- a/src/WebApi.cpp +++ b/src/WebApi.cpp @@ -97,6 +97,12 @@ void WebApiClass::init() _server.begin(); } +void WebApiClass::loop() +{ + // see: https://github.com/me-no-dev/ESPAsyncWebServer#limiting-the-number-of-web-socket-clients + _ws.cleanupClients(); +} + void WebApiClass::onNotFound(AsyncWebServerRequest* request) { // Handle Unknown Request diff --git a/src/main.cpp b/src/main.cpp index cfdbfb0..8cba74e 100644 --- a/src/main.cpp +++ b/src/main.cpp @@ -96,4 +96,6 @@ void loop() yield(); MqttPublishing.loop(); yield(); + WebApi.loop(); + yield(); } \ No newline at end of file