This commit is contained in:
Andrin Fassbind 2022-04-16 21:12:55 +02:00
parent 77e9cf6163
commit 6498b8ab33
3 changed files with 6 additions and 4 deletions

View File

@ -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");

View File

@ -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;

View File

@ -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();
}
/**