diff --git a/client/src/main/java/ch/zhaw/pm2/multichat/client/ClientConnectionHandler.java b/client/src/main/java/ch/zhaw/pm2/multichat/client/ClientConnectionHandler.java index 769ff94..2ed34e5 100644 --- a/client/src/main/java/ch/zhaw/pm2/multichat/client/ClientConnectionHandler.java +++ b/client/src/main/java/ch/zhaw/pm2/multichat/client/ClientConnectionHandler.java @@ -27,8 +27,7 @@ public class ClientConnectionHandler extends ConnectionHandler implements Runnab private final SimpleStringProperty userName; private final SimpleObjectProperty state; - private final ClientMessageList - messages; + private final ClientMessageList messages; private final SimpleStringProperty serverAddress; private final SimpleIntegerProperty serverPort; diff --git a/protocol/src/main/java/ch/zhaw/pm2/multichat/protocol/ConnectionHandler.java b/protocol/src/main/java/ch/zhaw/pm2/multichat/protocol/ConnectionHandler.java index 604865f..6cc5450 100644 --- a/protocol/src/main/java/ch/zhaw/pm2/multichat/protocol/ConnectionHandler.java +++ b/protocol/src/main/java/ch/zhaw/pm2/multichat/protocol/ConnectionHandler.java @@ -97,7 +97,12 @@ public abstract class ConnectionHandler { } else if (scanner.hasNextLine()) { receiver.append(scanner.nextLine()); } else { - throw new ChatProtocolException("No Receiver found"); + throw new ChatProtocolException("No Sender found"); + } + if (scanner.hasNextLine()) { + receiver.append(scanner.nextLine()); + } else { + throw new ChatProtocolException("No Reciever found"); } if (scanner.hasNextLine()) { type.append(scanner.nextLine()); @@ -119,7 +124,6 @@ public abstract class ConnectionHandler { */ protected void sendData(String sender, String receiver, String type, String payload) { if (connection.isAvailable()) { - new StringBuilder(); String data = sender + "\n" + receiver + "\n" + type + "\n" +