feat: partial implementation of MessageRelay and LobbyConnection
This commit is contained in:
parent
ce71de5d25
commit
89a75f982b
2
Gamelib
2
Gamelib
@ -1 +1 @@
|
|||||||
Subproject commit 56a90f6bdffd13012d086bb05ca06426214edb40
|
Subproject commit 1348e342d6ec3685424244ceae6d920652239555
|
@ -101,12 +101,11 @@ public class LobbyConnection {
|
|||||||
// Methods to send events
|
// Methods to send events
|
||||||
|
|
||||||
public void sendEvents(MessageSource target, Event... events) {
|
public void sendEvents(MessageSource target, Event... events) {
|
||||||
// TODO: implement
|
MessageRelay.getInstance().sendMessage(this, events, target);
|
||||||
MessageRelay.getInstance();
|
|
||||||
}
|
}
|
||||||
|
|
||||||
public void broadcastEvents(Event... events) {
|
public void broadcastEvents(Event... events) {
|
||||||
// TODO: implement
|
// TODO: implement
|
||||||
MessageRelay.getInstance();
|
MessageRelay.getInstance().broadcastEvents(this, events);
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
@ -1,6 +1,7 @@
|
|||||||
package uulm.teamname.marvelous.server.LobbyManager;
|
package uulm.teamname.marvelous.server.LobbyManager;
|
||||||
|
|
||||||
import org.java_websocket.WebSocket;
|
import org.java_websocket.WebSocket;
|
||||||
|
import uulm.teamname.marvelous.gamelibrary.events.Event;
|
||||||
import uulm.teamname.marvelous.server.Lobby.Lobby;
|
import uulm.teamname.marvelous.server.Lobby.Lobby;
|
||||||
|
|
||||||
import java.util.HashMap;
|
import java.util.HashMap;
|
||||||
@ -9,12 +10,10 @@ public class MessageRelay {
|
|||||||
|
|
||||||
public static MessageRelay instance;
|
public static MessageRelay instance;
|
||||||
|
|
||||||
private final HashMap<WebSocket, Lobby> lobbies;
|
private final HashMap<WebSocket, LobbyConnection> lobbies;
|
||||||
private final HashMap<Lobby, WebSocket> sockets;
|
|
||||||
|
|
||||||
private MessageRelay() {
|
private MessageRelay() {
|
||||||
this.lobbies = new HashMap<>();
|
this.lobbies = new HashMap<>();
|
||||||
this.sockets = new HashMap<>();
|
|
||||||
}
|
}
|
||||||
|
|
||||||
public static MessageRelay getInstance() {
|
public static MessageRelay getInstance() {
|
||||||
@ -30,7 +29,19 @@ public class MessageRelay {
|
|||||||
// TODO: send to target lobby
|
// 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: Create JSON
|
||||||
// TODO: send to target
|
// TODO: send to target
|
||||||
}
|
}
|
||||||
|
Loading…
Reference in New Issue
Block a user