Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Check for sending a close frame #603

Merged
merged 1 commit into from
Nov 9, 2017
Merged
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension


Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
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