You signed in with another tab or window. Reload to refresh your session.You signed out in another tab or window. Reload to refresh your session.You switched accounts on another tab or window. Reload to refresh your session.Dismiss alert
// The initial design of the library was doing a backup of the byte following the data buffer because the client code
663
-
// was allowed and documented to do something like data[len] = 0; to facilitate null-terminated string handling.
664
-
// This was a bit hacky but it was working and it was documented, although completely incorrect because it was modifying a byte outside of the data buffer.
665
-
// So to fix this behavior and to avoid breaking existing client code that may be relying on this behavior, we now have to copy the data to a temporary buffer that has an extra byte for the null terminator.
// The initial design of the library was doing a backup of the byte following the data buffer because the client code
734
-
// was allowed and documented to do something like data[len] = 0; to facilitate null-terminated string handling.
735
-
// This was a bit hacky but it was working and it was documented, although completely incorrect because it was modifying a byte outside of the data buffer.
736
-
// So to fix this behavior and to avoid breaking existing client code that may be relying on this behavior, we now have to copy the data to a temporary buffer that has an extra byte for the null terminator.
// The initial design of the library was doing a backup of the byte following the data buffer because the client code
739
+
// was allowed and documented to do something like data[len] = 0; to facilitate null-terminated string handling.
740
+
// This was a bit hacky but it was working and it was documented, although completely incorrect because it was modifying a byte outside of the data buffer.
741
+
// So to fix this behavior and to avoid breaking existing client code that may be relying on this behavior, we now have to copy the data to a temporary buffer that has an extra byte for the null terminator.
// - info->opcode stores the current WS frame type (binary, text, continuation)
745
+
// - info->message_opcode stores the WS frame type of the first frame of the message, which is used for fragmented messages to know the message type when processing subsequent frame with opcode 0 (continuation)
746
+
// So we can use info->message_opcode to avoid copying the data for non-text frames, and only copy the data for text frames when we need to add a null terminator for client code convenience.
Copy file name to clipboardExpand all lines: src/AsyncWebSocket.h
+3Lines changed: 3 additions & 0 deletions
Original file line number
Diff line number
Diff line change
@@ -236,6 +236,9 @@ class AsyncWebSocketClient {
236
236
void_runQueue();
237
237
void_clearQueue();
238
238
239
+
// this function is called when a text message is received, in order to copy the buffer and place a null terminator at the end of the buffer for easier handling of text messages.
0 commit comments