I've made a class which implements serializable. When I receive its object via my server-client application i'm only got its first instance, then no matter how many times the object has been modified the objectInputStream receives just the one what was sent for the first time.WHy?
This is actually a swing application There are running a chatpart and a gamepart on my application simultaneously.
the panel sends my game object to the server/client object
this.getServer1().sendGame(panel1.getMyGame());
public void sendGame(Game g1) throws IOException{
output.writeObject(g1);
output.flush();
}
the server or the client part is running on a thread
It reads data either from the gamepart or from the chatpart, the chatpart is works fine
Object next = input.readObject();
if (next instanceof Game) {
game1 = (Game)next;
panel1.setHisGame(game1);
}
else if (next instanceof String) {
message = (String)next;
...
}
the gameclass is just a simple class with some String attributes and the implements Serializable
I've solved it. Before the panel sends mygameobject to the server, I had to create the whole new object and fill it with the data of mygameobject. That's the way it can work.