8000 not send data if still in HTTP header handling · robokoding/arduinoWebSockets@516b104 · GitHub
[go: up one dir, main page]

Skip to content

Commit 516b104

Browse files
committed
not send data if still in HTTP header handling
1 parent afe1a2b commit 516b104

File tree

1 file changed

+10
-5
lines changed

1 file changed

+10
-5
lines changed

src/WebSockets.cpp

Lines changed: 10 additions & 5 deletions
Original file line numberDiff line numberDiff line change
@@ -63,18 +63,23 @@ void WebSockets::clientDisconnect(WSclient_t * client, uint16_t code, char * rea
6363
*/
6464
void WebSockets::sendFrame(WSclient_t * client, WSopcode_t opcode, uint8_t * payload, size_t length, bool mask, bool fin) {
6565

66+
if(!client->tcp.connected()) {
67+
DEBUG_WEBSOCKETS("[WS][%d][sendFrame] not Connected!?\n", client->num);
68+
return;
69+
}
70+
71+
if(client->status != WSC_CONNECTED) {
72+
DEBUG_WEBSOCKETS("[WS][%d][sendFrame] not in WSC_CONNECTED state!?\n", client->num);
73+
return;
74+
}
75+
6676
DEBUG_WEBSOCKETS("[WS][%d][sendFrame] ------- send massage frame -------\n", client->num);
6777
DEBUG_WEBSOCKETS("[WS][%d][sendFrame] fin: %u opCode: %u mask: %u length: %u\n", client->num, fin, opcode, mask, length);
6878

6979
if(opcode == WSop_text) {
7080
DEBUG_WEBSOCKETS("[WS][%d][sendFrame] text: %s\n", client->num, payload);
7181
}
7282

73-
if(!client->tcp.connected()) {
74-
DEBUG_WEBSOCKETS("[WS][%d][sendFrame] not Connected!?\n", client->num);
75-
return;
76-
}
77-
7883
uint8_t maskKey[4] = { 0 };
7984
uint8_t buffer[16] = { 0 };
8085
uint8_t i = 0;

0 commit comments

Comments
 (0)
0