40 lines
950 B
Java
40 lines
950 B
Java
package uulm.teamname.marvelous.server.LobbyManager;
|
|
|
|
import org.java_websocket.WebSocket;
|
|
import uulm.teamname.marvelous.server.Lobby.Lobby;
|
|
|
|
import java.util.HashMap;
|
|
|
|
public class MessageRelay {
|
|
|
|
public static MessageRelay instance;
|
|
|
|
private final HashMap<WebSocket, Lobby> lobbies;
|
|
private final HashMap<Lobby, WebSocket> sockets;
|
|
|
|
private MessageRelay() {
|
|
this.lobbies = new HashMap<>();
|
|
this.sockets = new HashMap<>();
|
|
}
|
|
|
|
public static MessageRelay getInstance() {
|
|
if (instance == null) {
|
|
instance = new MessageRelay();
|
|
}
|
|
return instance;
|
|
}
|
|
|
|
public void relayMessage (WebSocket conn, String message) {
|
|
var targetLobby = lobbies.get(conn);
|
|
// TODO: Parse JSON
|
|
// TODO: send to target lobby
|
|
}
|
|
|
|
public void broadcastEvents (Lobby origin/*, Event[] events*/) {
|
|
// TODO: Create JSON
|
|
// TODO: send to target
|
|
}
|
|
|
|
|
|
}
|