Objects in Sockets
Hi,
I'm writing a server <-> client application and I have a problem while sending Objects.
Generally, everything is fine as far as I don't want to send object back and forth. My problem by example:
- Server creates an object for instance myObject = new MyObject();
- Server puts an this object on a list myObjectList.add(myObject);
- Server sends the Object to the client via writeObject
- Client recives the package myObject = (myObject)input.readObject();
- Client sets a text in the object myObject.setText("Hello server");
- Client sends the object back to the server
- Server gets the object myObjectFromClient = (MyObject)input.readObject();
and here comes my problem out. Server will be reciving many such objects and he is going to check, which response did he get, but when I'll do a contains() check on a list of MyObjects: myObjectList.contains(myObjectFromClient); I'll get a false in result :(
Is there any way to recognize same objects when using sockets? one and obvious method is to set a field in an object with an ID and then I'll be able to recognize it when it gets back, but looks very non proffesional to me...
Thanks in advance
Maciej

