Added some Documenting. Added some fields to ClientAttributes.java that might be useful in case we need this class.
This commit is contained in:
parent
d8692152b4
commit
a10ea16d35
@ -23,9 +23,10 @@ public class CentralServerData {
|
||||
public static final BudaLogConfig l = new BudaLogConfig(LOGGER);
|
||||
|
||||
//TODO which datastructures should be used here?
|
||||
private Set<ClientHandler> clientsOnServer;
|
||||
private List<Lobby> allLobbies;
|
||||
private Map<Integer, Lobby> lobbyIDMap;
|
||||
//TODO Static or non static?
|
||||
private static Set<ClientHandler> clientsOnServer;
|
||||
private static List<Lobby> allLobbies;
|
||||
private static Map<Integer, Lobby> lobbyIDMap;
|
||||
|
||||
public CentralServerData() {
|
||||
clientsOnServer = new HashSet<>();
|
||||
@ -67,7 +68,7 @@ public class CentralServerData {
|
||||
public synchronized void removeClientFromLobby(ClientHandler client) {
|
||||
boolean foundAndRemoved = false;
|
||||
for (Lobby l : allLobbies) {
|
||||
foundAndRemoved = l.getPlayers().remove(client);
|
||||
foundAndRemoved = l.removePlayer(client);
|
||||
}
|
||||
LOGGER.debug("foundAndRemoved value: " + foundAndRemoved);
|
||||
}
|
||||
|
||||
@ -1,10 +1,18 @@
|
||||
package ch.unibas.dmi.dbis.cs108.sebaschi;
|
||||
|
||||
import ch.unibas.dmi.dbis.cs108.BudaLogConfig;
|
||||
import org.apache.logging.log4j.LogManager;
|
||||
import org.apache.logging.log4j.Logger;
|
||||
|
||||
/**
|
||||
* Attributes of a client visible to server.
|
||||
*/
|
||||
public class ClientAttributes {
|
||||
|
||||
String name;
|
||||
int id;
|
||||
public static final Logger LOGGER = LogManager.getLogger();
|
||||
public static final BudaLogConfig l = new BudaLogConfig(LOGGER);
|
||||
private String clientUserName;
|
||||
private boolean loggedIn;
|
||||
private boolean isInALobby;
|
||||
private Lobby clientsLobby;
|
||||
}
|
||||
|
||||
@ -127,4 +127,22 @@ public class Lobby {
|
||||
}
|
||||
}
|
||||
|
||||
/**
|
||||
* Does what is says on the box. Needs to be called when a client disconnects for some reason and
|
||||
* cannot reconnect. I.E. when the server closes the connection to that client, the client should
|
||||
* be removed from the list.
|
||||
*
|
||||
* @param player that is to be removed
|
||||
* @return true if a player was found and removed. Used for debugging.
|
||||
*/
|
||||
public synchronized boolean removePlayer(ClientHandler player) {
|
||||
return this.getPlayers().remove(player);
|
||||
}
|
||||
|
||||
public void broadcastToLounge(String msg) {
|
||||
for (ClientHandler lounger : this.getPlayers()) {
|
||||
|
||||
}
|
||||
}
|
||||
|
||||
}
|
||||
|
||||
Reference in New Issue
Block a user