synchronized addPlayer() in Lobby.addPlayer
This commit is contained in:
parent
37a8caa64d
commit
372a02a093
@ -223,6 +223,8 @@ public class ClientHandler implements Runnable {
|
|||||||
serverData.addLobbyToListOfAllLobbies(newGame);
|
serverData.addLobbyToListOfAllLobbies(newGame);
|
||||||
LOGGER.debug(
|
LOGGER.debug(
|
||||||
this.getClientUserName() + " created a new lobby with ID: " + newGame.getLobbyID());
|
this.getClientUserName() + " created a new lobby with ID: " + newGame.getLobbyID());
|
||||||
|
//TODO add server response. Here a possibility:
|
||||||
|
sendMsgToClient("New lobby with ID: " + newGame + " created.");
|
||||||
}
|
}
|
||||||
|
|
||||||
/**
|
/**
|
||||||
|
|||||||
@ -85,7 +85,7 @@ public class Lobby {
|
|||||||
* TODO: Does this method need to implemented somewhere else, e.g. in the ClientHandler?
|
* TODO: Does this method need to implemented somewhere else, e.g. in the ClientHandler?
|
||||||
* @param player who wants to join the lobby.
|
* @param player who wants to join the lobby.
|
||||||
*/
|
*/
|
||||||
public void addPlayer(ClientHandler player) {
|
public synchronized void addPlayer(ClientHandler player) {
|
||||||
if (players.size() <= MAX_NO_OF_CLIENTS) {
|
if (players.size() <= MAX_NO_OF_CLIENTS) {
|
||||||
players.add(player);
|
players.add(player);
|
||||||
numberOfPlayersInLobby++;
|
numberOfPlayersInLobby++;
|
||||||
|
|||||||
Reference in New Issue
Block a user