Skip to content

Commit e3fd7ad

Browse files
committed
Updated Websocket traces and improved WS example to send a fragmented message
1 parent 25b0628 commit e3fd7ad

2 files changed

Lines changed: 11 additions & 4 deletions

File tree

examples/WebSocket/WebSocket.ino

Lines changed: 9 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -180,16 +180,23 @@ void loop() {
180180
uint32_t now = millis();
181181

182182
if (now - lastWS >= deltaWS) {
183-
ws.printfAll("kp%.4f", (10.0 / 3.0));
183+
ws.printfAll("kp:%.4f", (10.0 / 3.0));
184184
lastWS = millis();
185185
}
186186

187-
if (now - lastHeap >= 2000) {
187+
if (now - lastHeap >= 5000) {
188188
Serial.printf("Connected clients: %u / %u total\n", ws.count(), ws.getClients().size());
189189

190190
// this can be called to also set a soft limit on the number of connected clients
191191
ws.cleanupClients(2); // no more than 2 clients
192192

193+
String random;
194+
random.reserve(8192);
195+
for (size_t i = 0; i < 8192; i++) {
196+
random += "x";
197+
}
198+
ws.textAll(random);
199+
193200
// ping twice (2 control frames)
194201
ws.pingAll();
195202
ws.pingAll();

src/AsyncWebSocket.cpp

Lines changed: 2 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -171,7 +171,7 @@ size_t AsyncWebSocketMessage::ack(size_t len, uint32_t time) {
171171
if (_sent >= _WSbuffer->size() && _acked >= _ack) {
172172
_status = WS_MSG_SENT;
173173
}
174-
async_ws_log_v("msg code: %" PRIu8 ", ack: %u/%u, remain=%u/%u, status: %d", _opcode, _acked, _ack, len - pending, len, static_cast<int>(_status));
174+
async_ws_log_v("opcode: %" PRIu8 ", acked: %u/%u, left: %u/%u, status: %d", _opcode, _acked, _ack, len - pending, len, static_cast<int>(_status));
175175
return len - pending;
176176
}
177177

@@ -224,7 +224,7 @@ size_t AsyncWebSocketMessage::send(AsyncClient *client) {
224224
_ack -= (toSend - sent);
225225
}
226226

227-
async_ws_log_v("C[%" PRIu16 "] Sent %u/%u, ack: %u/%u, final: %d", client->remotePort(), _sent, _WSbuffer->size(), _acked, _ack, final);
227+
async_ws_log_v("C[%" PRIu16 "] sent: %u/%u, final: %d, acked: %u/%u", client->remotePort(), _sent, _WSbuffer->size(), final, _acked, _ack);
228228
return sent;
229229
}
230230

0 commit comments

Comments
 (0)