From 516b1047f8cd04eae0b9d776c484186045db721a Mon Sep 17 00:00:00 2001 From: Markus Sattler Date: Sun, 26 Jul 2015 13:07:45 +0200 Subject: [PATCH] not send data if still in HTTP header handling --- src/WebSockets.cpp | 15 ++++++++++----- 1 file changed, 10 insertions(+), 5 deletions(-) diff --git a/src/WebSockets.cpp b/src/WebSockets.cpp index 28727d3..4310e56 100644 --- a/src/WebSockets.cpp +++ b/src/WebSockets.cpp @@ -63,6 +63,16 @@ void WebSockets::clientDisconnect(WSclient_t * client, uint16_t code, char * rea */ void WebSockets::sendFrame(WSclient_t * client, WSopcode_t opcode, uint8_t * payload, size_t length, bool mask, bool fin) { + if(!client->tcp.connected()) { + DEBUG_WEBSOCKETS("[WS][%d][sendFrame] not Connected!?\n", client->num); + return; + } + + if(client->status != WSC_CONNECTED) { + DEBUG_WEBSOCKETS("[WS][%d][sendFrame] not in WSC_CONNECTED state!?\n", client->num); + return; + } + DEBUG_WEBSOCKETS("[WS][%d][sendFrame] ------- send massage frame -------\n", client->num); DEBUG_WEBSOCKETS("[WS][%d][sendFrame] fin: %u opCode: %u mask: %u length: %u\n", client->num, fin, opcode, mask, length); @@ -70,11 +80,6 @@ void WebSockets::sendFrame(WSclient_t * client, WSopcode_t opcode, uint8_t * pay DEBUG_WEBSOCKETS("[WS][%d][sendFrame] text: %s\n", client->num, payload); } - if(!client->tcp.connected()) { - DEBUG_WEBSOCKETS("[WS][%d][sendFrame] not Connected!?\n", client->num); - return; - } - uint8_t maskKey[4] = { 0 }; uint8_t buffer[16] = { 0 }; uint8_t i = 0;