Skip to content

Commit

Permalink
VE.Direct: websocket and status API response size (#371)
Browse files Browse the repository at this point in the history
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.
  • Loading branch information
schlimmchen committed Aug 10, 2023
1 parent b721416 commit 7c7a15e
Show file tree
Hide file tree
Showing 2 changed files with 3 additions and 2 deletions.
1 change: 1 addition & 0 deletions include/WebApi_ws_vedirect_live.h
Original file line number Diff line number Diff line change
Expand Up @@ -23,4 +23,5 @@ class WebApiWsVedirectLiveClass {
uint32_t _lastVedirectUpdateCheck = 0;
uint32_t _lastWsCleanup = 0;
uint32_t _newestVedirectTimestamp = 0;
static constexpr uint16_t _responseSize = 1024 + 128;
};
4 changes: 2 additions & 2 deletions src/WebApi_ws_vedirect_live.cpp
Original file line number Diff line number Diff line change
Expand Up @@ -61,7 +61,7 @@ void WebApiWsVedirectLiveClass::loop()
String buffer;
// free JsonDocument as soon as possible
{
DynamicJsonDocument root(2048);
DynamicJsonDocument root(_responseSize);
JsonVariant var = root;
generateJsonResponse(var);
serializeJson(root, buffer);
Expand Down Expand Up @@ -173,7 +173,7 @@ void WebApiWsVedirectLiveClass::onLivedataStatus(AsyncWebServerRequest* request)
return;
}
try {
AsyncJsonResponse* response = new AsyncJsonResponse(false, 1024U);
AsyncJsonResponse* response = new AsyncJsonResponse(false, _responseSize);
JsonVariant root = response->getRoot();

generateJsonResponse(root);
Expand Down

0 comments on commit 7c7a15e

Please sign in to comment.