diff options
author | Vitaly Takmazov | 2018-07-01 20:32:42 +0300 |
---|---|---|
committer | Vitaly Takmazov | 2018-07-01 20:32:42 +0300 |
commit | 2e6c77c1db5b1017c8701c3b016c62d3b100fd64 (patch) | |
tree | b5b46db8b872579c87099bf2a03d458ed187767d /juick-server/src/main | |
parent | 0963fd937d119eaa5f8aa5174e5de3eb6c990007 (diff) |
ws: ConcurrentWebSocketSessionDecorator in handleTextMessage
Diffstat (limited to 'juick-server/src/main')
-rw-r--r-- | juick-server/src/main/java/com/juick/server/WebsocketManager.java | 12 |
1 files changed, 6 insertions, 6 deletions
diff --git a/juick-server/src/main/java/com/juick/server/WebsocketManager.java b/juick-server/src/main/java/com/juick/server/WebsocketManager.java index 1d09ad77..360f6c1c 100644 --- a/juick-server/src/main/java/com/juick/server/WebsocketManager.java +++ b/juick-server/src/main/java/com/juick/server/WebsocketManager.java @@ -154,16 +154,16 @@ public class WebsocketManager extends TextWebSocketHandler { @Override protected void handleTextMessage(WebSocketSession session, TextMessage message) throws Exception { - User user = clients.stream().filter(c -> c.session.getDelegate().equals(session)).map(c -> c.visitor) - .findFirst().orElse(AnonymousUser.INSTANCE); - if (!user.isAnonymous()) { + SocketSubscribed ws = clients.stream().filter(c -> c.session.getDelegate().equals(session)) + .findFirst().orElseThrow(IllegalStateException::new); + if (!ws.visitor.isAnonymous()) { String command = message.getPayload().trim(); if (StringUtils.isNotEmpty(command)) { - CommandResult result = commandsManager.processCommand(user, command, URI.create("")); - session.sendMessage(new TextMessage(result.getText())); + CommandResult result = commandsManager.processCommand(ws.visitor, command, URI.create("")); + ws.session.sendMessage(new TextMessage(result.getText())); } } else { - session.sendMessage(new TextMessage("Authorization required")); + ws.session.sendMessage(new TextMessage("Authorization required")); } } |