P
Patrick
I have a very simple java application in which I need to pass an
object via sockets. It is an object that I have defined, which has
implemented Serializable. The problem occurs when I send an instance
of the object, when I recieve it on the other end, it is null. The
reciever does in fact recieve an object of the correct type (my user
defined object) but it is empty although the one I sent was not. Is
there something I need to do in the readObject() or writeObject()
methods? Any help would be appreciated, thank you!
For reference, here is my user defined object:
class nodeMessage implements Serializable
{
String text;
int messageID;
int senderID;
int recieverID;
String[] stamp;
public nodeMessage(){}
public nodeMessage(String t, int mID, int sID, int rID,
String[] s)
{
text = t;
messageID = mID;
senderID = sID;
recieverID = rID;
stamp = s;
}
public String getText()
{
return text;
}
public int getMID()
{
return messageID;
}
public int getSID()
{
return senderID;
}
public int getRID()
{
return recieverID;
}
public String[] getStamp()
{
return stamp;
}
public void addStamp(String s)
{
stamp[stamp.length] = s;
}
private void writeObject(java.ibjectOutputStream out)
throws IOException{
}
private void readObject(java.ibjectInputStream in)
throws IOException, ClassNotFoundException{
}
}
object via sockets. It is an object that I have defined, which has
implemented Serializable. The problem occurs when I send an instance
of the object, when I recieve it on the other end, it is null. The
reciever does in fact recieve an object of the correct type (my user
defined object) but it is empty although the one I sent was not. Is
there something I need to do in the readObject() or writeObject()
methods? Any help would be appreciated, thank you!
For reference, here is my user defined object:
class nodeMessage implements Serializable
{
String text;
int messageID;
int senderID;
int recieverID;
String[] stamp;
public nodeMessage(){}
public nodeMessage(String t, int mID, int sID, int rID,
String[] s)
{
text = t;
messageID = mID;
senderID = sID;
recieverID = rID;
stamp = s;
}
public String getText()
{
return text;
}
public int getMID()
{
return messageID;
}
public int getSID()
{
return senderID;
}
public int getRID()
{
return recieverID;
}
public String[] getStamp()
{
return stamp;
}
public void addStamp(String s)
{
stamp[stamp.length] = s;
}
private void writeObject(java.ibjectOutputStream out)
throws IOException{
}
private void readObject(java.ibjectInputStream in)
throws IOException, ClassNotFoundException{
}
}