diff --git a/html/main.js b/html/main.js index 94edf9d..59ef74a 100644 --- a/html/main.js +++ b/html/main.js @@ -72,6 +72,7 @@ connection.onmessage = function(event){ case "updateScoreboard": updateScoreboard(data.scores); break; + default: console.log("Unknown message type:", data.type); } diff --git a/src/main/java/uta/cse3310/App.java b/src/main/java/uta/cse3310/App.java index d7f5660..5c5287c 100644 --- a/src/main/java/uta/cse3310/App.java +++ b/src/main/java/uta/cse3310/App.java @@ -150,6 +150,11 @@ public void onMessage(WebSocket conn, String message) { case "highlight": handleHighlightMessage(conn , json); break; + + case "giveMehint": + sendHint(conn); + break; + @@ -325,6 +330,19 @@ private SubLobby findSubLobbyContainingPlayer(Player player) { return null; } + public void sendHint(WebSocket conn) { + + for (SubLobby subLobby : ActiveGames) { + + for (Player player : subLobby.getPlayers()) { + if (player.getConn().equals(conn)) { + subLobby.sendHintJson(); + return; + } + } + } + System.out.println("Request for hint from a connection not in any active sub-lobby."); + }