Skip to content

Commit

Permalink
Check for sending a close frame
Browse files Browse the repository at this point in the history
  • Loading branch information
marci4 committed Nov 9, 2017
1 parent caed0d5 commit 7bc8fa1
Show file tree
Hide file tree
Showing 2 changed files with 10 additions and 5 deletions.
3 changes: 3 additions & 0 deletions pom.xml
Original file line number Diff line number Diff line change
Expand Up @@ -7,6 +7,9 @@
<name>Java-WebSocket</name>
<description>A barebones WebSocket client and server implementation written 100% in Java</description>
<url>https://github.com/TooTallNate/Java-WebSocket</url>
<properties>
<project.build.sourceEncoding>UTF-8</project.build.sourceEncoding>
</properties>
<licenses>
<license>
<name>MIT License</name>
Expand Down
12 changes: 7 additions & 5 deletions src/main/java/org/java_websocket/WebSocketImpl.java
Original file line number Diff line number Diff line change
Expand Up @@ -424,11 +424,13 @@ public void close( int code, String message, boolean remote ) {
wsl.onWebsocketError( this, e );
}
}
CloseFrame closeFrame = new CloseFrame();
closeFrame.setReason( message );
closeFrame.setCode( code );
closeFrame.isValid();
sendFrame( closeFrame );
if (isOpen()) {
CloseFrame closeFrame = new CloseFrame();
closeFrame.setReason( message );
closeFrame.setCode( code );
closeFrame.isValid();
sendFrame( closeFrame );
}
} catch ( InvalidDataException e ) {
wsl.onWebsocketError( this, e );
flushAndClose( CloseFrame.ABNORMAL_CLOSE, "generated frame is invalid", false );
Expand Down

0 comments on commit 7bc8fa1

Please sign in to comment.