@@ -151,7 +151,7 @@ void WebSockets::sendFrame(WSclient_t * client, WSopcode_t opcode, uint8_t * pay
151151 if (fin) {
152152 *headerPtr |= bit (7 ); // /< set Fin
153153 }
154- *headerPtr |= opcode; // /< set opcode
154+ *headerPtr |= opcode; // /< set opcode
155155 headerPtr++;
156156
157157 // byte 1
@@ -167,7 +167,7 @@ void WebSockets::sendFrame(WSclient_t * client, WSopcode_t opcode, uint8_t * pay
167167 *headerPtr = ((length >> 8 ) & 0xFF ); headerPtr++;
168168 *headerPtr = (length & 0xFF ); headerPtr++;
169169 } else {
170- // normaly we never get here (to less memory)
170+ // Normally we never get here (to less memory)
171171 *headerPtr |= 127 ; headerPtr++;
172172 *headerPtr = 0x00 ; headerPtr++;
173173 *headerPtr = 0x00 ; headerPtr++;
@@ -181,6 +181,8 @@ void WebSockets::sendFrame(WSclient_t * client, WSopcode_t opcode, uint8_t * pay
181181
182182 if (mask) {
183183 if (useInternBuffer) {
184+ // if we use a Intern Buffer we can modify the data
185+ // by this fact its possible the do the masking
184186 for (uint8_t x = 0 ; x < sizeof (maskKey); x++) {
185187 maskKey[x] = random (0xFF );
186188 *headerPtr = maskKey[x]; headerPtr++;
@@ -206,6 +208,10 @@ void WebSockets::sendFrame(WSclient_t * client, WSopcode_t opcode, uint8_t * pay
206208 }
207209 }
208210
211+ #ifndef NODEBUG_WEBSOCKETS
212+ unsigned long start = micros ();
213+ #endif
214+
209215 if (headerToPayload) {
210216 // header has be added to payload
211217 // payload is forced to reserved 14 Byte but we may not need all based on the length and mask settings
@@ -221,6 +227,8 @@ void WebSockets::sendFrame(WSclient_t * client, WSopcode_t opcode, uint8_t * pay
221227 }
222228 }
223229
230+ DEBUG_WEBSOCKETS (" [WS][%d][sendFrame] sending Frame Done (%uus).\n " , client->num , (micros () - start));
231+
224232#ifdef WEBSOCKETS_USE_BIG_MEM
225233 if (useInternBuffer && payloadPtr) {
226234 free (payloadPtr);
@@ -275,7 +283,7 @@ void WebSockets::handleWebsocket(WSclient_t * client) {
275283 }
276284 payloadLen = buffer[0 ] << 8 | buffer[1 ];
277285 } else if (payloadLen == 127 ) {
278- // read 64bit inteager as length
286+ // read 64bit integer as length
279287 if (!readWait (client, buffer, 8 )) {
280288 // timeout
281289 clientDisconnect (client, 1002 );
@@ -436,7 +444,12 @@ bool WebSockets::readWait(WSclient_t * client, uint8_t *out, size_t n) {
436444 size_t len;
437445
438446 while (n > 0 ) {
439- if (client->tcp && !client->tcp ->connected ()) {
447+ if (!client->tcp ) {
448+ DEBUG_WEBSOCKETS (" [readWait] tcp is null!\n " );
449+ return false ;
450+ }
451+
452+ if (!client->tcp ->connected ()) {
440453 DEBUG_WEBSOCKETS (" [readWait] not connected!\n " );
441454 return false ;
442455 }
0 commit comments