Skip to content

Commit

Permalink
Support messages with null chars
Browse files Browse the repository at this point in the history
  • Loading branch information
Bob Corsaro committed Apr 20, 2011
1 parent 7948fa2 commit f49e998
Showing 1 changed file with 6 additions and 2 deletions.
8 changes: 6 additions & 2 deletions src/net/tootallnate/websocket/WebSocket.java
Original file line number Diff line number Diff line change
Expand Up @@ -86,6 +86,8 @@ public final class WebSocket {
* the proper order.
*/
private Object bufferQueueMutex = new Object();

private boolean readingState = false;


// CONSTRUCTOR /////////////////////////////////////////////////////////////
Expand Down Expand Up @@ -212,10 +214,12 @@ public SocketChannel socketChannel() {
private void recieveFrame() {
byte newestByte = this.buffer.get();

if (newestByte == START_OF_FRAME) { // Beginning of Frame
if (newestByte == START_OF_FRAME && !readingState) { // Beginning of Frame
this.currentFrame = null;
readingState = true;

} else if (newestByte == END_OF_FRAME) { // End of Frame
} else if (newestByte == END_OF_FRAME && readingState) { // End of Frame
readingState = false;
String textFrame = null;
// currentFrame will be null if END_OF_FRAME was send directly after
// START_OF_FRAME, thus we will send 'null' as the sent message.
Expand Down

0 comments on commit f49e998

Please sign in to comment.