Skip to content

Commit de9955a

Browse files
committed
-made close frames require a close frame in response before closing the
underlying socket
1 parent f1cf984 commit de9955a

File tree

2 files changed

+4
-12
lines changed

2 files changed

+4
-12
lines changed

‎src/main/java/org/java_websocket/SocketChannelIOHelper.java‎

Lines changed: 2 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -59,11 +59,11 @@ public static boolean batch( WebSocketImpl ws, ByteChannel sockchannel ) throws
5959
} while ( buffer != null );
6060
}
6161

62-
if( ws.outQueue.isEmpty() && ws.isFlushAndClose() /*&& ( c == null || c.isNeedWrite() )*/){
62+
/*if( ws.outQueue.isEmpty() && ws.isFlushAndClose() ){//
6363
synchronized ( ws ){
6464
ws.closeConnection();
6565
}
66-
}
66+
}*/
6767
returnc != null ? !( (WrappedByteChannel) sockchannel ).isNeedWrite() : true;
6868
}
6969

‎src/main/java/org/java_websocket/WebSocketImpl.java‎

Lines changed: 2 additions & 10 deletions
Original file line numberDiff line numberDiff line change
@@ -149,15 +149,11 @@ public WebSocketImpl( WebSocketListener listener , List<Draft> drafts , Socket s
149149
publicvoiddecode( ByteBuffersocketBuffer ){
150150
assert ( socketBuffer.hasRemaining() );
151151

152-
if( flushandclosestate ){
153-
return;
154-
}
155-
156152
if( DEBUG )
157153
System.out.println( "process(" + socketBuffer.remaining() + "):{" + ( socketBuffer.remaining() > 1000 ? "too big to display" : newString( socketBuffer.array(), socketBuffer.position(), socketBuffer.remaining() ) ) + "}" );
158154

159-
if( readystate==READYSTATE.OPEN ){
160-
decodeFrames( socketBuffer );
155+
if( readystate!=READYSTATE.NOT_YET_CONNECTED ){
156+
decodeFrames( socketBuffer );;
161157
} else{
162158
if( decodeHandshake( socketBuffer ) ){
163159
assert ( tmpHandshakeBytes.hasRemaining() != socketBuffer.hasRemaining() || !socketBuffer.hasRemaining() ); // the buffers will never have remaining bytes at the same time
@@ -312,17 +308,13 @@ private boolean decodeHandshake( ByteBuffer socketBufferNew ){
312308
}
313309

314310
privatevoiddecodeFrames( ByteBuffersocketBuffer ){
315-
if( flushandclosestate )
316-
return;
317311

318312
List<Framedata> frames;
319313
try{
320314
frames = draft.translateFrame( socketBuffer );
321315
for( Framedataf : frames ){
322316
if( DEBUG )
323317
System.out.println( "matched frame: " + f );
324-
if( flushandclosestate )
325-
return;
326318
Opcodecurop = f.getOpcode();
327319
booleanfin = f.isFin();
328320

0 commit comments

Comments
(0)