diff --git a/Server/src/main/java/uulm/teamname/marvelous/server/lobbymanager/LobbyManager.java b/Server/src/main/java/uulm/teamname/marvelous/server/lobbymanager/LobbyManager.java index c02e45f..b31d366 100644 --- a/Server/src/main/java/uulm/teamname/marvelous/server/lobbymanager/LobbyManager.java +++ b/Server/src/main/java/uulm/teamname/marvelous/server/lobbymanager/LobbyManager.java @@ -60,7 +60,7 @@ public class LobbyManager { targetedLobby = initializeNewLobby(resourceDescriptor); } else { Logger.info("No free lobby spot available, sending error and disconnecting Client"); - + // TODO: Implement this! } } else if (targetedLobby.isFull() && !message.role.equals(RoleEnum.SPECTATOR)) { @@ -100,9 +100,9 @@ public class LobbyManager { synchronized (lobbies) { lobbies.put(participant, targetedLobby); } - if (targetedLobby.isFull() && !LobbyRunner.getInstance().isStarted(targetedLobby)) { - Logger.info("Lobby '{}' was full, starting...", targetedLobby.gameID); - LobbyRunner.getInstance().startLobby(targetedLobby); + if (targetedLobby.isFull()) { + Logger.trace("Lobby is full, checking whether to start lobby or not"); + startLobby(targetedLobby); } } return participant; @@ -174,7 +174,14 @@ public class LobbyManager { } Logger.trace("Returning local resourceDescriptor"); return localResourceDescriptor; + } + /** Checks whether the current lobby is already started, and if that is not the case, starts it */ + private void startLobby(LobbyConnection targetedLobby) { + if (!LobbyRunner.getInstance().isStarted(targetedLobby)) { + Logger.info("Starting Lobby '{}' ...", targetedLobby.gameID); + LobbyRunner.getInstance().startLobby(targetedLobby); + } } /** A method to obtain the lobbies HashMap. Meant for testing, and shouldn't be used anywhere else. */