File tree Expand file tree Collapse file tree 5 files changed +37
-11
lines changed Expand file tree Collapse file tree 5 files changed +37
-11
lines changed Original file line number Diff line number Diff line change @@ -60,13 +60,13 @@ jobs:
6060 run : arduino-cli core install --additional-urls "${{ matrix.index_url }}" ${{ matrix.core }}
6161
6262 - name : Install AsyncTCP
63- run : ARDUINO_LIBRARY_ENABLE_UNSAFE_INSTALL=true arduino-cli lib install --git-url https://github.com/mathieucarbou/AsyncTCP#v3.2.5
63+ run : ARDUINO_LIBRARY_ENABLE_UNSAFE_INSTALL=true arduino-cli lib install --git-url https://github.com/mathieucarbou/AsyncTCP#v3.2.6
6464
6565 - name : Install ESPAsyncTCP
6666 run : ARDUINO_LIBRARY_ENABLE_UNSAFE_INSTALL=true arduino-cli lib install --git-url https://github.com/mathieucarbou/esphome-ESPAsyncTCP#v2.0.0
6767
6868 - name : Install ESPAsyncWebServer
69- run : ARDUINO_LIBRARY_ENABLE_UNSAFE_INSTALL=true arduino-cli lib install --git-url https://github.com/mathieucarbou/ESPAsyncWebServer#v3.2.4
69+ run : ARDUINO_LIBRARY_ENABLE_UNSAFE_INSTALL=true arduino-cli lib install --git-url https://github.com/mathieucarbou/ESPAsyncWebServer#v3.3.11
7070
7171 - name : Build Demo
7272 run : arduino-cli compile --library . --warnings none -b ${{ matrix.board }} "examples/Demo/Demo.ino"
Original file line number Diff line number Diff line change @@ -56,6 +56,7 @@ void loop() {
5656 if (millis () - last > 50 ) {
5757#endif
5858 count++;
59+
5960 long r = random (10 , 250 ) + 15 ;
6061 String buffer;
6162 buffer.reserve (r);
@@ -67,7 +68,16 @@ void loop() {
6768 for (int i = 0 ; i < r; i++) {
6869 buffer += dict[random (0 , 62 )];
6970 }
71+
72+ #ifdef WSL_HIGH_PERF
73+ // Using internal websocket buffer to improve memory consumption and avoid another internal copy when enqueueing the message
74+ AsyncWebSocketMessageBuffer* wsBuffer = WebSerial.makeBuffer (buffer.length ());
75+ memmove (wsBuffer->get (), buffer.c_str (), buffer.length ());
76+ WebSerial.send (wsBuffer);
77+ #else
7078 WebSerial.print (buffer);
79+ #endif
80+
7181 last = millis ();
7282 }
7383}
Original file line number Diff line number Diff line change 2222 {
2323 "owner" : " mathieucarbou" ,
2424 "name" : " ESPAsyncWebServer" ,
25- "version" : " ^3.2.4 " ,
25+ "version" : " ^3.3.11 " ,
2626 "platforms" : [" espressif8266" , " espressif32" ]
2727 }
2828 ]
Original file line number Diff line number Diff line change @@ -9,8 +9,7 @@ build_flags =
99 -D WS_MAX_QUEUED_MESSAGES =128
1010 -D WSL_HIGH_PERF
1111lib_deps =
12- mathieucarbou/AsyncTCP@^3.2.5
13- mathieucarbou/ESPAsyncWebServer@^3.2.4
12+ mathieucarbou/ESPAsyncWebServer@^3.3.11
1413lib_compat_mode = strict
1514lib_ldf_mode = chain
1615upload_protocol = esptool
@@ -43,9 +42,6 @@ board = esp32-s3-devkitc-1
4342platform = espressif8266
4443board = huzzah
4544; board = d1_mini
46- lib_deps =
47- mathieucarbou/ESPAsyncWebServer@^3.2.4
48- esphome/ESPAsyncTCP-esphome@^2.0.0
4945
5046; CI
5147
@@ -64,6 +60,3 @@ board = ${sysenv.PIO_BOARD}
6460[env:ci-esp8266]
6561platform = espressif8266
6662board = ${sysenv.PIO_BOARD}
67- lib_deps =
68- mathieucarbou/ESPAsyncWebServer@^3.2.4
69- esphome/ESPAsyncTCP-esphome@^2.0.0
Original file line number Diff line number Diff line change @@ -114,6 +114,29 @@ class WebSerialClass : public Print {
114114 // The buffer is not enabled by default.
115115 void setBuffer (size_t initialCapacity);
116116
117+ #ifdef WSL_HIGH_PERF
118+ #ifdef ASYNCWEBSERVER_FORK_mathieucarbou
119+ // Expose the internal WebSocket makeBuffer to even improve memory consumption on client-side
120+ // 1. make a AsyncWebSocketMessageBuffer
121+ // 2. put the data inside
122+ // 3. send the buffer
123+ // This method avoids a buffer copy when creating the WebSocket message
124+ AsyncWebSocketMessageBuffer* makeBuffer (size_t size = 0 ) {
125+ if (!_ws)
126+ return nullptr ;
127+ return _ws->makeBuffer (size);
128+ }
129+
130+ void send (AsyncWebSocketMessageBuffer* buffer) {
131+ if (!_ws || !buffer)
132+ return ;
133+ _ws->cleanupClients (WSL_MAX_WS_CLIENTS);
134+ if (_ws->count ())
135+ _ws->textAll (buffer);
136+ }
137+ #endif
138+ #endif
139+
117140 private:
118141 // Server
119142 AsyncWebServer *_server;
You can’t perform that action at this time.
0 commit comments