From 2e6c77c1db5b1017c8701c3b016c62d3b100fd64 Mon Sep 17 00:00:00 2001 From: Vitaly Takmazov Date: Sun, 1 Jul 2018 20:32:42 +0300 Subject: ws: ConcurrentWebSocketSessionDecorator in handleTextMessage --- .../src/main/java/com/juick/server/WebsocketManager.java | 12 ++++++------ 1 file changed, 6 insertions(+), 6 deletions(-) (limited to 'juick-server/src/main/java/com') 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")); } } -- cgit v1.2.3