Skip to content

Commit f49e998

Browse files
author
Bob Corsaro
committed
Support messages with null chars
1 parent 7948fa2 commit f49e998

File tree

1 file changed

+6
-2
lines changed

1 file changed

+6
-2
lines changed

src/net/tootallnate/websocket/WebSocket.java

Lines changed: 6 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -86,6 +86,8 @@ public final class WebSocket {
8686
* the proper order.
8787
*/
8888
private Object bufferQueueMutex = new Object();
89+
90+
private boolean readingState = false;
8991

9092

9193
// CONSTRUCTOR /////////////////////////////////////////////////////////////
@@ -212,10 +214,12 @@ public SocketChannel socketChannel() {
212214
private void recieveFrame() {
213215
byte newestByte = this.buffer.get();
214216

215-
if (newestByte == START_OF_FRAME) { // Beginning of Frame
217+
if (newestByte == START_OF_FRAME && !readingState) { // Beginning of Frame
216218
this.currentFrame = null;
219+
readingState = true;
217220

218-
} else if (newestByte == END_OF_FRAME) { // End of Frame
221+
} else if (newestByte == END_OF_FRAME && readingState) { // End of Frame
222+
readingState = false;
219223
String textFrame = null;
220224
// currentFrame will be null if END_OF_FRAME was send directly after
221225
// START_OF_FRAME, thus we will send 'null' as the sent message.

0 commit comments

Comments
 (0)