finnished listAllLobbiesToClient()
This commit is contained in:
parent
922561d522
commit
6297439c3c
@ -227,15 +227,27 @@ public class ClientHandler implements Runnable {
|
||||
sendMsgToClient(Protocol.printToClientConsole + "$New lobby with ID: " + newGame + " created.");
|
||||
}
|
||||
|
||||
public void listAllLobbies() {
|
||||
/**
|
||||
* Creates a list of all lobbies to send to client after LISTL command. Uses
|
||||
* Lobby.getIdAndAdminForList() to build a formated list for the client. used in
|
||||
* JServerProtocolParser.
|
||||
*/
|
||||
public void listAllLobbiesToClient() {
|
||||
StringBuilder response = new StringBuilder();
|
||||
response.append(Protocol.pingBack);
|
||||
response.append("$");
|
||||
if (serverData.getAllLobbies().isEmpty()) {
|
||||
sendMsgToClient(Protocol.printToClientConsole +"$There are currently no open lobbies");
|
||||
response.append("There are currently no open lobbies");
|
||||
LOGGER.debug("No open lobbies");
|
||||
} else {
|
||||
StringBuilder response = new StringBuilder();
|
||||
|
||||
for (Lobby l : serverData.getAllLobbies()) {
|
||||
response.append(l.getIdAndAdminForList());
|
||||
}
|
||||
}
|
||||
LOGGER.debug(
|
||||
"RESPONSE TO LISTL: " + response.toString() + " requested by: " + this.clientUserName);
|
||||
sendMsgToClient(response.toString());
|
||||
}
|
||||
|
||||
/**
|
||||
* Closes the client's socket, in, and out.
|
||||
|
||||
Reference in New Issue
Block a user