Skip to content

Commit

Permalink
Merge pull request #603 from marci4/master
Browse files Browse the repository at this point in the history
Check for sending a close frame
  • Loading branch information
marci4 authored Nov 9, 2017
2 parents e43bb76 + 7bc8fa1 commit 87f5210
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 87f5210

Please sign in to comment.