fixed #49
This commit is contained in:
parent
77e9cf6163
commit
6498b8ab33
|
@ -123,7 +123,7 @@ public class ClientConnectionHandler extends ConnectionHandler implements Runnab
|
||||||
try {
|
try {
|
||||||
System.out.println("Start receiving data...");
|
System.out.println("Start receiving data...");
|
||||||
while (getConnection().isAvailable()) {
|
while (getConnection().isAvailable()) {
|
||||||
Message data = (Message) getConnection().receive();
|
Message data = getConnection().receive();
|
||||||
processData(data);
|
processData(data);
|
||||||
}
|
}
|
||||||
System.out.println("Stopped receiving data");
|
System.out.println("Stopped receiving data");
|
||||||
|
|
|
@ -1,9 +1,11 @@
|
||||||
package ch.zhaw.pm2.multichat.protocol;
|
package ch.zhaw.pm2.multichat.protocol;
|
||||||
|
|
||||||
|
import java.io.Serializable;
|
||||||
|
|
||||||
/**
|
/**
|
||||||
* A Message object represents one Message of a client. Can be stored in ClientMessageList.
|
* 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 final ConnectionHandler.DATA_TYPE type;
|
||||||
private String sender;
|
private String sender;
|
||||||
private final String receiver;
|
private final String receiver;
|
||||||
|
|
|
@ -320,9 +320,9 @@ public class NetworkHandler {
|
||||||
* @throws IOException if an error occours. (e.g. terminated locally/remotely) see above.
|
* @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
|
* @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());
|
ObjectInputStream inputStream = new ObjectInputStream(this.socket.getInputStream());
|
||||||
return (T) inputStream.readObject();
|
return (Message) inputStream.readObject();
|
||||||
}
|
}
|
||||||
|
|
||||||
/**
|
/**
|
||||||
|
|
Loading…
Reference in New Issue