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 28bcc0d..eab747b 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 @@ -123,7 +123,7 @@ public class ClientConnectionHandler extends ConnectionHandler implements Runnab try { System.out.println("Start receiving data..."); while (getConnection().isAvailable()) { - Message data = (Message) getConnection().receive(); + Message data = getConnection().receive(); processData(data); } System.out.println("Stopped receiving data"); diff --git a/protocol/src/main/java/ch/zhaw/pm2/multichat/protocol/Message.java b/protocol/src/main/java/ch/zhaw/pm2/multichat/protocol/Message.java index 0c5976c..d64ee80 100644 --- a/protocol/src/main/java/ch/zhaw/pm2/multichat/protocol/Message.java +++ b/protocol/src/main/java/ch/zhaw/pm2/multichat/protocol/Message.java @@ -1,9 +1,11 @@ package ch.zhaw.pm2.multichat.protocol; +import java.io.Serializable; + /** * A Message object represents one Message of a client. Can be stored in ClientMessageList. */ -public class Message { +public class Message implements Serializable { private final ConnectionHandler.DATA_TYPE type; private String sender; private final String receiver; diff --git a/protocol/src/main/java/ch/zhaw/pm2/multichat/protocol/NetworkHandler.java b/protocol/src/main/java/ch/zhaw/pm2/multichat/protocol/NetworkHandler.java index 20d20ad..02c5b09 100644 --- a/protocol/src/main/java/ch/zhaw/pm2/multichat/protocol/NetworkHandler.java +++ b/protocol/src/main/java/ch/zhaw/pm2/multichat/protocol/NetworkHandler.java @@ -320,9 +320,9 @@ public class NetworkHandler { * @throws IOException if an error occours. (e.g. terminated locally/remotely) see above. * @throws ClassNotFoundException if the data object received does not match any class in the local classpath */ - public T receive() throws IOException, ClassNotFoundException { + public Message receive() throws IOException, ClassNotFoundException { ObjectInputStream inputStream = new ObjectInputStream(this.socket.getInputStream()); - return (T) inputStream.readObject(); + return (Message) inputStream.readObject(); } /**