44import java .util .Collections ;
55import java .util .LinkedList ;
66import java .util .List ;
7+ import java .util .Random ;
78
89import net .tootallnate .websocket .Charsetfunctions ;
910import net .tootallnate .websocket .Draft ;
@@ -36,6 +37,7 @@ public class Draft_75 extends Draft {
3637 public static final byte END_OF_FRAME = (byte ) 0xFF ;
3738
3839 private boolean readingState = false ;
40+ private boolean inframe = false ;
3941
4042 private ByteBuffer currentFrame ;
4143
@@ -106,17 +108,17 @@ public List<Framedata> translateFrame( ByteBuffer buffer ) throws InvalidDataExc
106108 this .currentFrame = null ;
107109 readingState = true ;
108110 } else if ( newestByte == END_OF_FRAME && readingState ) { // End of Frame
109- readingState = false ;
110- String textFrame = null ;
111111 // currentFrame will be null if END_OF_FRAME was send directly after
112112 // START_OF_FRAME, thus we will send 'null' as the sent message.
113113 if ( this .currentFrame != null ) {
114114 FramedataImpl1 curframe = new FramedataImpl1 ();
115115 curframe .setPayload ( currentFrame .array () );
116116 curframe .setFin ( true );
117- curframe .setOptcode ( Opcode .TEXT );
117+ curframe .setOptcode ( inframe ? Opcode . CONTINIOUS : Opcode .TEXT );
118118 frames .add ( curframe );
119119 }
120+ readingState = false ;
121+ inframe = false ;
120122 } else { // Regular frame data, add to current frame buffer //TODO This code is very expensive and slow
121123 ByteBuffer frame = ByteBuffer .allocate ( checkAlloc ( ( this .currentFrame != null ? this .currentFrame .capacity () : 0 ) + 1 ) );
122124 if ( this .currentFrame != null ) {
@@ -131,7 +133,8 @@ public List<Framedata> translateFrame( ByteBuffer buffer ) throws InvalidDataExc
131133 FramedataImpl1 curframe = new FramedataImpl1 ();
132134 curframe .setPayload ( currentFrame .array () );
133135 curframe .setFin ( false );
134- curframe .setOptcode ( Opcode .TEXT );
136+ curframe .setOptcode ( inframe ? Opcode .CONTINIOUS : Opcode .TEXT );
137+ inframe = true ;
135138 frames .add ( curframe );
136139 }
137140 return frames ;
0 commit comments