Skip to content

Commit 8e00ff7

Browse files
committed
Added traces in sent method
1 parent 3aa7059 commit 8e00ff7

1 file changed

Lines changed: 7 additions & 5 deletions

File tree

src/AsyncWebSocket.cpp

Lines changed: 7 additions & 5 deletions
Original file line numberDiff line numberDiff line change
@@ -177,22 +177,25 @@ size_t AsyncWebSocketMessage::ack(size_t len, uint32_t time) {
177177

178178
size_t AsyncWebSocketMessage::send(AsyncClient *client) {
179179
if (!client) {
180+
async_ws_log_v("No client");
180181
return 0;
181182
}
182183

183184
if (_status != WS_MSG_SENDING) {
185+
async_ws_log_v("Wrong status: got: %d, expected: %d", static_cast<int>(_status), static_cast<int>(WS_MSG_SENDING));
184186
return 0;
185187
}
186188

187189
if (_sent == _WSbuffer->size()) {
188190
if (_acked == _ack) {
189191
_status = WS_MSG_SENT;
190192
}
193+
async_ws_log_v("Already sent: %u/%u", _sent, _WSbuffer->size());
191194
return 0;
192195
}
193196
if (_sent > _WSbuffer->size()) {
194197
_status = WS_MSG_ERROR;
195-
// ets_printf("E: %u > %u\n", _sent, _WSbuffer->length());
198+
async_ws_log_v("Error, sent more: %u/%u", _sent, _WSbuffer->size());
196199
return 0;
197200
}
198201

@@ -201,6 +204,7 @@ size_t AsyncWebSocketMessage::send(AsyncClient *client) {
201204

202205
// not enough space in lwip buffer ?
203206
if (!window) {
207+
async_ws_log_v("No space left to send more data: acked: %u, sent: %u, remaining: %u", _acked, _sent, toSend);
204208
return 0;
205209
}
206210

@@ -209,20 +213,18 @@ size_t AsyncWebSocketMessage::send(AsyncClient *client) {
209213
_sent += toSend;
210214
_ack += toSend + ((toSend < 126) ? 2 : 4) + (_mask * 4);
211215

212-
// ets_printf("W: %u %u\n", _sent - toSend, toSend);
213-
214216
bool final = (_sent == _WSbuffer->size());
215217
uint8_t *dPtr = (uint8_t *)(_WSbuffer->data() + (_sent - toSend));
216218
uint8_t opCode = (toSend && _sent == toSend) ? _opcode : (uint8_t)WS_CONTINUATION;
217219

218220
size_t sent = webSocketSendFrame(client, final, opCode, _mask, dPtr, toSend);
219221
_status = WS_MSG_SENDING;
220222
if (toSend && sent != toSend) {
221-
// ets_printf("E: %u != %u\n", toSend, sent);
222223
_sent -= (toSend - sent);
223224
_ack -= (toSend - sent);
224225
}
225-
// ets_printf("S: %u %u\n", _sent, sent);
226+
227+
async_ws_log_v("Sent %u/%u, ack: %u/%u, final: %d", _sent, _WSbuffer->size(), _acked, _ack, final);
226228
return sent;
227229
}
228230

0 commit comments

Comments
 (0)