VE.Direct: websocket and status API response size (#371)

the size allocated for the HTTP request response was too little, while
the size for the buffer of the websocket output was increased already.

add a new member variable and use it in both context, such that
increasing the buffer size to accomodate more space (for the JSON data
in particular) will benefit both contexts in the future.
This commit is contained in:
Bernhard Kirchen 2023-08-10 13:40:09 +02:00 committed by GitHub
parent b7214161b8
commit 7c7a15e016
No known key found for this signature in database
GPG Key ID: 4AEE18F83AFDEB23
2 changed files with 3 additions and 2 deletions

View File

@ -23,4 +23,5 @@ private:
uint32_t _lastVedirectUpdateCheck = 0; uint32_t _lastVedirectUpdateCheck = 0;
uint32_t _lastWsCleanup = 0; uint32_t _lastWsCleanup = 0;
uint32_t _newestVedirectTimestamp = 0; uint32_t _newestVedirectTimestamp = 0;
static constexpr uint16_t _responseSize = 1024 + 128;
}; };

View File

@ -61,7 +61,7 @@ void WebApiWsVedirectLiveClass::loop()
String buffer; String buffer;
// free JsonDocument as soon as possible // free JsonDocument as soon as possible
{ {
DynamicJsonDocument root(2048); DynamicJsonDocument root(_responseSize);
JsonVariant var = root; JsonVariant var = root;
generateJsonResponse(var); generateJsonResponse(var);
serializeJson(root, buffer); serializeJson(root, buffer);
@ -173,7 +173,7 @@ void WebApiWsVedirectLiveClass::onLivedataStatus(AsyncWebServerRequest* request)
return; return;
} }
try { try {
AsyncJsonResponse* response = new AsyncJsonResponse(false, 1024U); AsyncJsonResponse* response = new AsyncJsonResponse(false, _responseSize);
JsonVariant root = response->getRoot(); JsonVariant root = response->getRoot();
generateJsonResponse(root); generateJsonResponse(root);