update to async web server

This commit is contained in:
cjkas 2026-03-24 08:02:10 +01:00
parent 73f39d67c3
commit a55dc7f66b
8 changed files with 1089 additions and 2966 deletions

View file

@ -1,4 +1,6 @@
#include "WResp.h"
#include <WebServer.h>
#include <esp_task_wdt.h>
void JsonSockEvent::beginEvent(AsyncWebSocket *server, const char *evt, char *buff, size_t buffSize) {
this->server = server;
this->buff = buff;
@ -69,6 +71,7 @@ void JsonResponse::_safecat(const char *val, bool escape) {
}
void AsyncJsonResp::beginResponse(AsyncWebServerRequest *request, char *buff, size_t buffSize) {
this->_request = request;
this->buff = buff;
this->buffSize = buffSize;
this->buff[0] = 0x00;
@ -78,6 +81,9 @@ void AsyncJsonResp::beginResponse(AsyncWebServerRequest *request, char *buff, si
}
void AsyncJsonResp::endResponse() {
if(strlen(this->buff)) this->flush();
if(this->_request && this->_stream) {
this->_request->send(this->_stream);
}
}
void AsyncJsonResp::flush() {
if(this->_stream && strlen(this->buff) > 0) {