Changed functionality of listAllLobbiesToClient():
Now it writes to the OutPutStream itself instead of sending a CHATM to client. Hope is that the JClientParser only has to parse once.
This commit is contained in:
parent
e23a749f55
commit
da5189311e
@ -88,6 +88,7 @@ public class Client {
|
|||||||
try {
|
try {
|
||||||
chatMsg = in.readLine(); //todo: maybe if
|
chatMsg = in.readLine(); //todo: maybe if
|
||||||
if (chatMsg != null) {
|
if (chatMsg != null) {
|
||||||
|
//LOGGER.debug("chatMSG recieved from Server: " + chatMsg);
|
||||||
parse(chatMsg);
|
parse(chatMsg);
|
||||||
} else { System.out.println("chatMsg is null"); throw new IOException();}
|
} else { System.out.println("chatMsg is null"); throw new IOException();}
|
||||||
} catch (IOException e) {
|
} catch (IOException e) {
|
||||||
|
|||||||
@ -179,6 +179,7 @@ public class ClientHandler implements Runnable {
|
|||||||
*/
|
*/
|
||||||
public void sendMsgToClient(String msg) {
|
public void sendMsgToClient(String msg) {
|
||||||
try {
|
try {
|
||||||
|
if(!msg.equals("SPING"))LOGGER.debug("Message sent to client: " + msg);
|
||||||
out.write(msg);
|
out.write(msg);
|
||||||
out.newLine();
|
out.newLine();
|
||||||
out.flush();
|
out.flush();
|
||||||
@ -236,19 +237,26 @@ public class ClientHandler implements Runnable {
|
|||||||
*/
|
*/
|
||||||
public void listAllLobbiesToClient() {
|
public void listAllLobbiesToClient() {
|
||||||
StringBuilder response = new StringBuilder();
|
StringBuilder response = new StringBuilder();
|
||||||
response.append(Protocol.printToClientConsole);
|
response.append(Protocol.listLobbies);
|
||||||
response.append("$");
|
response.append("$");
|
||||||
if (serverData.getAllLobbies().isEmpty()) {
|
if (serverData.getAllLobbies().isEmpty()) {
|
||||||
response.append("There are currently no open lobbies");
|
response.append("There are currently no open lobbies");
|
||||||
LOGGER.debug("No open lobbies");
|
LOGGER.debug("No open lobbies");
|
||||||
} else {
|
} else {
|
||||||
for (Lobby l : serverData.getAllLobbies()) {
|
for (Lobby l : serverData.getAllLobbies()) {
|
||||||
sendMsgToClient(response + l.getIdAndAdminAndFormat());
|
response.append(l.getIdAndAdminAndFormat());
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
LOGGER.debug(
|
LOGGER.debug(
|
||||||
"RESPONSE TO LISTL: " + response.toString() + " requested by: " + this.clientUserName);
|
"RESPONSE TO LISTL: " + response.toString() + " requested by: " + this.clientUserName);
|
||||||
//sendMsgToClient(response.toString());
|
try {
|
||||||
|
out.write(response.toString());
|
||||||
|
out.newLine();
|
||||||
|
out.flush();
|
||||||
|
} catch (IOException e) {
|
||||||
|
LOGGER.debug(e.getMessage());
|
||||||
|
}
|
||||||
|
|
||||||
}
|
}
|
||||||
|
|
||||||
/**
|
/**
|
||||||
|
|||||||
Reference in New Issue
Block a user