From e41fadd87977f3fdff311eacf52b2b66b882335e Mon Sep 17 00:00:00 2001 From: Robert Eberle <123016766+TresEberle@users.noreply.github.com> Date: Mon, 29 Apr 2024 20:07:29 -0500 Subject: [PATCH] Update App.java --- src/main/java/uta/cse3310/App.java | 11 ++++++----- 1 file changed, 6 insertions(+), 5 deletions(-) diff --git a/src/main/java/uta/cse3310/App.java b/src/main/java/uta/cse3310/App.java index 12ab4e8..a7cd765 100644 --- a/src/main/java/uta/cse3310/App.java +++ b/src/main/java/uta/cse3310/App.java @@ -153,7 +153,8 @@ public void onClose(WebSocket conn, int code, String reason, boolean remote) { } @Override - public void onMessage(WebSocket conn, String message) { + public void onMessage(WebSocket conn, String message) + { System.out.println("Received message from client: " + message); // Parse the incoming message to extract sender and content @@ -190,15 +191,14 @@ public void onMessage(WebSocket conn, String message) { String sender = mO.getSender(); String content = mO.getContent(); System.out.println(sender + " : " + content); - if ("playerNick".equals(mO.getContent())) - ; + if ("playerNick".equals(mO.getContent())); { String chatMessage = sender + ":" + content; String jsonMessage = gson.toJson(new Message(player, content)); broadcast(chatMessage); // broadcast(message); - } + } // if (message.contains("content")) { // Use JSON parsing to extract sender and content @@ -233,7 +233,8 @@ public void onMessage(WebSocket conn, String message) { // since the lobby has changed, let's send it out to everyone String jsonString = gson.toJson(L); - broadcast(jsonString); + conn.send(jsonString); + //broadcast(jsonString); // Player.printPlayerList(); // broadcastPlayerList(); // }