|
12 | 12 | importorg.java_websocket.exceptions.InvalidHandshakeException; |
13 | 13 | importorg.java_websocket.exceptions.LimitExedeedException; |
14 | 14 | importorg.java_websocket.framing.CloseFrame; |
| 15 | +importorg.java_websocket.framing.FrameBuilder; |
15 | 16 | importorg.java_websocket.framing.Framedata; |
| 17 | +importorg.java_websocket.framing.Framedata.Opcode; |
| 18 | +importorg.java_websocket.framing.FramedataImpl1; |
16 | 19 | importorg.java_websocket.handshake.ClientHandshake; |
17 | 20 | importorg.java_websocket.handshake.ClientHandshakeBuilder; |
18 | 21 | importorg.java_websocket.handshake.HandshakeBuilder; |
@@ -46,6 +49,8 @@ public enum CloseHandshakeType{ |
46 | 49 | /** In some cases the handshake will be parsed different depending on whether */ |
47 | 50 | protectedRolerole = null; |
48 | 51 |
|
| 52 | +protectedOpcodecontinuousFrameType = null; |
| 53 | + |
49 | 54 | publicstaticByteBufferreadLine( ByteBufferbuf ){ |
50 | 55 | ByteBuffersbuf = ByteBuffer.allocate( buf.remaining() ); |
51 | 56 | byteprev = '0'; |
@@ -123,6 +128,34 @@ protected boolean basicAccept( Handshakedata handshakedata ){ |
123 | 128 |
|
124 | 129 | publicabstractList<Framedata> createFrames( Stringtext, booleanmask ); |
125 | 130 |
|
| 131 | +publicList<Framedata> continuousFrame( Opcodeop, ByteBufferbuffer, booleanfin ){ |
| 132 | +if( op != Opcode.BINARY && op != Opcode.TEXT && op != Opcode.TEXT ){ |
| 133 | +thrownewIllegalArgumentException( "Only Opcode.BINARY or Opcode.TEXT are allowed" ); |
| 134 | + } |
| 135 | + |
| 136 | +if( continuousFrameType != null ){ |
| 137 | +continuousFrameType = Opcode.CONTINUOUS; |
| 138 | + } elseif( fin ){ |
| 139 | +thrownewIllegalArgumentException( "There is no continious frame to continue" ); |
| 140 | + } else{ |
| 141 | +continuousFrameType = op; |
| 142 | + } |
| 143 | + |
| 144 | +FrameBuilderbui = newFramedataImpl1( continuousFrameType ); |
| 145 | +try{ |
| 146 | +bui.setPayload( buffer ); |
| 147 | + } catch ( InvalidDataExceptione ){ |
| 148 | +thrownewRuntimeException( e ); // can only happen when one builds close frames(Opcode.Close) |
| 149 | + } |
| 150 | +bui.setFin( fin ); |
| 151 | +if( fin ){ |
| 152 | +continuousFrameType = null; |
| 153 | + } else{ |
| 154 | +continuousFrameType = op; |
| 155 | + } |
| 156 | +returnCollections.singletonList( (Framedata) bui ); |
| 157 | + } |
| 158 | + |
126 | 159 | publicabstractvoidreset(); |
127 | 160 |
|
128 | 161 | publicList<ByteBuffer> createHandshake( Handshakedatahandshakedata, Roleownrole ){ |
|
0 commit comments