diff --git a/html/oldIndex.html b/html/oldIndex.html index 26c2037..c5cebad 100644 --- a/html/oldIndex.html +++ b/html/oldIndex.html @@ -18,7 +18,6 @@

Welcome to The Word Search Game

-
@@ -91,15 +90,15 @@

The Word Search Game

Game1

-
text
+

Game2

-
text
+

Game3

-
text
+

Game4

-
text
+

Game5

-
text
+
@@ -157,6 +156,8 @@

Leaderboard

var attemptArr;//array of cell numbers in an attempt var score; var playerColor=""; + var message=""; + var allMessages=new Array(); socket.onopen = function(evt) { console.log("Open"); requestGameList(); @@ -254,11 +255,16 @@

Leaderboard

document.getElementsByClassName("Room").innerHTML=""; for(i=0;iLeaderboard console.log("GameId after confirmation: "+gameId); var mode = document.getElementById('modeSelect').value; playerColor = document.getElementById('playerColor').value; - player.nick=nick; if (!nick) @@ -322,7 +327,7 @@

Leaderboard

alert('Please select a game and mode.'); return; } - + sendChat(nick,document.getElementById('nickInput').value.trim()); joinGame(nick, gameIndex, mode); }); @@ -539,5 +544,15 @@

Leaderboard

socket.send(JSON.stringify(data)); } + +function sendChat(nick,message) +{ + var data={ + type: "message", + message: message, + player: nick + } + socket.send(JSON.stringify(data)); +} diff --git a/src/main/java/uta/cse3310/App.java b/src/main/java/uta/cse3310/App.java index dab8064..8e9ea34 100644 --- a/src/main/java/uta/cse3310/App.java +++ b/src/main/java/uta/cse3310/App.java @@ -322,8 +322,15 @@ public void toLobby() { // Logic for navigating to the lobby } - public void globalChat() { - // Logic for handling global chat + public void globalChat(Gson gson, JsonObject object) + { + // Logic for handling local chat + JsonObject jsonObject=new JsonObject(); + jsonObject.addProperty("type","message"); + jsonObject.addProperty("message",object.get("message").getAsString()); + jsonObject.addProperty("player",object.get("player").getAsString()); + + broadcast(jsonObject.toString()); } public void getPlayerColor() { @@ -507,6 +514,9 @@ public void messageHandler(Gson gson, String jsonString, WebSocket conn) case("updateLobby"): updateLobby(gson,jsonObject); break; + case("message"): + globalChat(gson,object); + break; default: System.out.println("Unexpected message");