@@ -151,7 +151,7 @@ void WebSockets::sendFrame(WSclient_t * client, WSopcode_t opcode, uint8_t * pay
151
151
if (fin) {
152
152
*headerPtr |= bit (7 ); // /< set Fin
153
153
}
154
- *headerPtr |= opcode; // /< set opcode
154
+ *headerPtr |= opcode; // /< set opcode
155
155
headerPtr++;
156
156
157
157
// byte 1
@@ -167,7 +167,7 @@ void WebSockets::sendFrame(WSclient_t * client, WSopcode_t opcode, uint8_t * pay
167
167
*headerPtr = ((length >> 8 ) & 0xFF ); headerPtr++;
168
168
*headerPtr = (length & 0xFF ); headerPtr++;
169
169
} else {
170
- // normaly we never get here (to less memory)
170
+ // Normally we never get here (to less memory)
171
171
*headerPtr |= 127 ; headerPtr++;
172
172
*headerPtr = 0x00 ; headerPtr++;
173
173
*headerPtr = 0x00 ; headerPtr++;
@@ -181,6 +181,8 @@ void WebSockets::sendFrame(WSclient_t * client, WSopcode_t opcode, uint8_t * pay
181
181
182
182
if (mask) {
183
183
if (useInternBuffer) {
184
+ // if we use a Intern Buffer we can modify the data
185
+ // by this fact its possible the do the masking
184
186
for (uint8_t x = 0 ; x < sizeof (maskKey); x++) {
185
187
maskKey[x] = random (0xFF );
186
188
*headerPtr = maskKey[x]; headerPtr++;
@@ -206,6 +208,10 @@ void WebSockets::sendFrame(WSclient_t * client, WSopcode_t opcode, uint8_t * pay
206
208
}
207
209
}
208
210
211
+ #ifndef NODEBUG_WEBSOCKETS
212
+ unsigned long start = micros ();
213
+ #endif
214
+
209
215
if (headerToPayload) {
210
216
// header has be added to payload
211
217
// 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
221
227
}
222
228
}
223
229
230
+ DEBUG_WEBSOCKETS (" [WS][%d][sendFrame] sending Frame Done (%uus).\n " , client->num , (micros () - start));
231
+
224
232
#ifdef WEBSOCKETS_USE_BIG_MEM
225
233
if (useInternBuffer && payloadPtr) {
226
234
free (payloadPtr);
@@ -275,7 +283,7 @@ void WebSockets::handleWebsocket(WSclient_t * client) {
275
283
}
276
284
payloadLen = buffer[0 ] << 8 | buffer[1 ];
277
285
} else if (payloadLen == 127 ) {
278
- // read 64bit inteager as length
286
+ // read 64bit integer as length
279
287
if (!readWait (client, buffer, 8 )) {
280
288
// timeout
281
289
clientDisconnect (client, 1002 );
@@ -436,7 +444,12 @@ bool WebSockets::readWait(WSclient_t * client, uint8_t *out, size_t n) {
436
444
size_t len;
437
445
438
446
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 ()) {
440
453
DEBUG_WEBSOCKETS (" [readWait] not connected!\n " );
441
454
return false ;
442
455
}
0 commit comments