diff --git a/CheckersServer/core/src/com/mygdx/game/controller/ServerController.java b/CheckersServer/core/src/com/mygdx/game/controller/ServerController.java index 235f54833f55795cc90be926b1a111357105d834..f4e6270e481cc398b2ee5f682e11651cb1cf4de0 100644 --- a/CheckersServer/core/src/com/mygdx/game/controller/ServerController.java +++ b/CheckersServer/core/src/com/mygdx/game/controller/ServerController.java @@ -72,6 +72,7 @@ public class ServerController { if(lobby.getPlayersID().contains(id)){ ArrayList<Connection> connections = getConnections(lobby); cLobbyLeave command = new cLobbyLeave(leaveLobby(id, lobby.getID())); + leaveLobby(id, lobby.getID()); for(Connection c : connections){ c.sendTCP(command); } diff --git a/CheckersServer/core/src/com/mygdx/game/controller/commands/cLobbyLeave.java b/CheckersServer/core/src/com/mygdx/game/controller/commands/cLobbyLeave.java index c2f7762b135dd553f0b70c9de7bc2525d488ab13..94880d8fdaedcef329a05fb5778530e24ad56a1f 100644 --- a/CheckersServer/core/src/com/mygdx/game/controller/commands/cLobbyLeave.java +++ b/CheckersServer/core/src/com/mygdx/game/controller/commands/cLobbyLeave.java @@ -25,14 +25,16 @@ public class cLobbyLeave extends Command{ playerId = (int) receivedData.get(1); Lobby lobby = net.getLobby(lobbyId); + data = net.leaveLobby(playerId, lobbyId); //Find new lobby without player System.out.printf("Request from Player w. ID: %d to leave Lobby w. ID: %d \n", playerId, lobbyId); for (Connection c : net.getConnections(lobby)) { - c.sendTCP(this); + if (c.getID() != playerId) c.sendTCP(this); //send new lobby to other players } - net.leaveLobby(playerId, lobbyId); + data = new Lobby(-1); //Send empty lobby to the player who left + connection.sendTCP(this); net.getPlayer(playerId).setIsPlayerReady(false); } }