1
0
mirror of https://github.com/s00500/ESPUI.git synced 2024-11-22 04:00:55 +00:00

Knowing websocket msg string length

This commit is contained in:
Lukas Bachschwell 2019-04-15 12:41:22 +02:00
parent 2c6aaf82f4
commit 36cfe78205

View File

@ -294,6 +294,7 @@ void onWsEvent(AsyncWebSocket *server, AsyncWebSocketClient *client, AwsEventTyp
case WS_EVT_DATA: { case WS_EVT_DATA: {
String msg = ""; String msg = "";
msg.reserve(len + 1);
for (size_t i = 0; i < len; i++) { for (size_t i = 0; i < len; i++) {
msg += (char)data[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) { void ESPUIClass::jsonDom(AsyncWebSocketClient *client) {
String json; String json;
DynamicJsonDocument document(8000); DynamicJsonDocument document(4000);
document["type"] = (int)UI_INITIAL_GUI; document["type"] = (int)UI_INITIAL_GUI;
JsonArray items = document.createNestedArray("controls"); JsonArray items = document.createNestedArray("controls");