Skip to content

Commit 877314d

Browse files
author
Kristijan Sedlak
committed
close socket connection issue fix (connection do not close when manually calling close())
1 parent b1b0934 commit 877314d

File tree

1 file changed

+3
-6
lines changed

1 file changed

+3
-6
lines changed

src/net/tootallnate/websocket/WebSocketClient.java

Lines changed: 3 additions & 6 deletions
Original file line numberDiff line numberDiff line change
@@ -120,8 +120,9 @@ public void close() throws IOException
120120
{
121121
if (running)
122122
{
123+
running = false; // must be called to stop do loop
123124
selector.wakeup();
124-
conn.close();
125+
conn.close(); // synchronously calling onClose(conn)
125126
}
126127
}
127128

@@ -364,11 +365,7 @@ public void onOpen(WebSocket conn) {
364365
*/
365366
public void onClose(WebSocket conn)
366367
{
367-
if (running)
368-
{
369-
onClose();
370-
}
371-
368+
onClose();
372369
releaseAndInitialize();
373370
}
374371

0 commit comments

Comments
 (0)