Guest_imported
New member
- Jan 1, 1970
- 0
In the client part of a chatprogram i want to be able to recieve multiple types of objects from the input stream. the code i have kinda works.
String from, msg, tempMSG;
Vector tempClientData;
Object tempObject;
while (running) {
try {
tempObject=in.readObject();
listener.messageReceived("Server", tempObject.toString(), this); //this displays the object to the client. It is the original vector not the new one? I don't understand?
try {
tempMSG=(String) tempObject;
StringTokenizer token=new StringTokenizer(tempMSG, ">>>>"
if(token.countTokens()==2) {
from=token.nextToken();
msg=token.nextToken();
listener.messageReceived(from, msg, this);
}
} catch(Exception e) {
tempClientData=(Vector) tempObject;
userList.updateList(tempClientData);
}
} catch(Exception e) {
e.printStackTrace();
stopRunning();
}
}
it works fine the first time the vector is sent over, but when another vector is sent to replace it, it receives the same vector(or think it receives the same vector). I have done all the testing possible on the server side of the application and it is sending the updated vector.
String from, msg, tempMSG;
Vector tempClientData;
Object tempObject;
while (running) {
try {
tempObject=in.readObject();
listener.messageReceived("Server", tempObject.toString(), this); //this displays the object to the client. It is the original vector not the new one? I don't understand?
try {
tempMSG=(String) tempObject;
StringTokenizer token=new StringTokenizer(tempMSG, ">>>>"
if(token.countTokens()==2) {
from=token.nextToken();
msg=token.nextToken();
listener.messageReceived(from, msg, this);
}
} catch(Exception e) {
tempClientData=(Vector) tempObject;
userList.updateList(tempClientData);
}
} catch(Exception e) {
e.printStackTrace();
stopRunning();
}
}
it works fine the first time the vector is sent over, but when another vector is sent to replace it, it receives the same vector(or think it receives the same vector). I have done all the testing possible on the server side of the application and it is sending the updated vector.