diff options
Diffstat (limited to 'juick-server/src/main/java/com')
-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")); } } |