aboutsummaryrefslogtreecommitdiff
path: root/src/main/java/com/juick
diff options
context:
space:
mode:
Diffstat (limited to 'src/main/java/com/juick')
-rw-r--r--src/main/java/com/juick/ws/WebsocketComponent.java9
1 files changed, 6 insertions, 3 deletions
diff --git a/src/main/java/com/juick/ws/WebsocketComponent.java b/src/main/java/com/juick/ws/WebsocketComponent.java
index 7399c298..8ccccb3b 100644
--- a/src/main/java/com/juick/ws/WebsocketComponent.java
+++ b/src/main/java/com/juick/ws/WebsocketComponent.java
@@ -103,9 +103,12 @@ public class WebsocketComponent extends TextWebSocketHandler {
@Override
public void afterConnectionClosed(WebSocketSession session, CloseStatus status) throws Exception {
synchronized (clients) {
- clients.stream().filter(c -> c.session.getId().equals(session.getId())).forEach(c -> {
- logger.info(String.format("session %s closed with status %s", c.clientName, status.getCode()));
- clients.remove(c);
+ clients.removeIf(c -> {
+ if (c.session.equals(session)) {
+ logger.info(String.format("session from %s closed with status %d", c.clientName, status.getCode()));
+ return true;
+ }
+ return false;
});
}