Knowing websocket msg string length

This commit is contained in:
Lukas Bachschwell 2019-04-15 12:41:22 +02:00
parent 2c6aaf82f4
commit 36cfe78205
1 changed files with 2 additions and 1 deletions

View File

@ -294,6 +294,7 @@ void onWsEvent(AsyncWebSocket *server, AsyncWebSocketClient *client, AwsEventTyp
case WS_EVT_DATA: {
String msg = "";
msg.reserve(len + 1);
for (size_t i = 0; i < len; i++) {
msg += (char)data[i];
@ -575,7 +576,7 @@ sent as one blob at the beginning. Therefore a new type is used as well
*/
void ESPUIClass::jsonDom(AsyncWebSocketClient *client) {
String json;
DynamicJsonDocument document(8000);
DynamicJsonDocument document(4000);
document["type"] = (int)UI_INITIAL_GUI;
JsonArray items = document.createNestedArray("controls");