From a8168f0df91b29eb4723f8c19f6611d0bc679774 Mon Sep 17 00:00:00 2001 From: Guillaume Le Floch Date: Thu, 30 Sep 2021 16:26:09 +0200 Subject: [PATCH] Fix WebSocket code example according to the given test --- docs/src/main/asciidoc/websockets.adoc | 7 +++++-- 1 file changed, 5 insertions(+), 2 deletions(-) diff --git a/docs/src/main/asciidoc/websockets.adoc b/docs/src/main/asciidoc/websockets.adoc index 1328aeaacbd4e..25f0b1e136e88 100644 --- a/docs/src/main/asciidoc/websockets.adoc +++ b/docs/src/main/asciidoc/websockets.adoc @@ -102,7 +102,6 @@ public class ChatSocket { @OnOpen public void onOpen(Session session, @PathParam("username") String username) { sessions.put(username, session); - broadcast("User " + username + " joined"); } @OnClose @@ -119,7 +118,11 @@ public class ChatSocket { @OnMessage public void onMessage(String message, @PathParam("username") String username) { - broadcast(">> " + username + ": " + message); + if (message.equalsIgnoreCase("_ready_")) { + broadcast("User " + username + " joined"); + } else { + broadcast(">> " + username + ": " + message); + } } private void broadcast(String message) {