diff --git a/Gamelib b/Gamelib index 56a90f6..1348e34 160000 --- a/Gamelib +++ b/Gamelib @@ -1 +1 @@ -Subproject commit 56a90f6bdffd13012d086bb05ca06426214edb40 +Subproject commit 1348e342d6ec3685424244ceae6d920652239555 diff --git a/Server/src/main/java/uulm/teamname/marvelous/server/LobbyManager/LobbyConnection.java b/Server/src/main/java/uulm/teamname/marvelous/server/LobbyManager/LobbyConnection.java index a209421..c4fba19 100644 --- a/Server/src/main/java/uulm/teamname/marvelous/server/LobbyManager/LobbyConnection.java +++ b/Server/src/main/java/uulm/teamname/marvelous/server/LobbyManager/LobbyConnection.java @@ -101,12 +101,11 @@ public class LobbyConnection { // Methods to send events public void sendEvents(MessageSource target, Event... events) { - // TODO: implement - MessageRelay.getInstance(); + MessageRelay.getInstance().sendMessage(this, events, target); } public void broadcastEvents(Event... events) { // TODO: implement - MessageRelay.getInstance(); + MessageRelay.getInstance().broadcastEvents(this, events); } } diff --git a/Server/src/main/java/uulm/teamname/marvelous/server/LobbyManager/MessageRelay.java b/Server/src/main/java/uulm/teamname/marvelous/server/LobbyManager/MessageRelay.java index f05a3ff..9b0fd25 100644 --- a/Server/src/main/java/uulm/teamname/marvelous/server/LobbyManager/MessageRelay.java +++ b/Server/src/main/java/uulm/teamname/marvelous/server/LobbyManager/MessageRelay.java @@ -1,6 +1,7 @@ package uulm.teamname.marvelous.server.LobbyManager; import org.java_websocket.WebSocket; +import uulm.teamname.marvelous.gamelibrary.events.Event; import uulm.teamname.marvelous.server.Lobby.Lobby; import java.util.HashMap; @@ -9,12 +10,10 @@ public class MessageRelay { public static MessageRelay instance; - private final HashMap lobbies; - private final HashMap sockets; + private final HashMap lobbies; private MessageRelay() { this.lobbies = new HashMap<>(); - this.sockets = new HashMap<>(); } public static MessageRelay getInstance() { @@ -30,7 +29,19 @@ public class MessageRelay { // TODO: send to target lobby } - public void broadcastEvents (Lobby origin/*, Event[] events*/) { + public void sendMessage (LobbyConnection origin, Event[] events, MessageSource target) { + switch (target) { + + case Player1 -> { + } + case Player2 -> { + } + case Spectator -> { + } + } + } + + public void broadcastEvents (LobbyConnection origin, Event[] events) { // TODO: Create JSON // TODO: send to target }