try {
jt.setEditable(true);
while (true) {
CommandIF comm = (CommandIF) din.readObject();
// for reading normal messages
if (comm.getCommand().equals(ProtocolConstants.COMMAND_SEND)) {
boolean show = (!comm.isPrivateMessage())
|| comm.getMsgFrom().equals(sendername);
Iterator itr = comm.getRecipientNames().iterator();
boolean flag = false;
mess = comm.getMessage();
while (itr.hasNext()) {
if (itr.next().toString().equals(sendername)) {
flag = true;
mess = " (private message)\n" + mess;
}
}
show = show || flag;
if (show) {
//mess = comm.getMessage();
jt.append(mess + "\n");
}
}// if
// for updating peer list.
if (comm.getCommand().equals(ProtocolConstants.UPDATE_PEER_LIST)) {
List list = comm.getNewPeerList();
ch.removeAll();
Iterator itr = list.iterator();
ch.addItem(ProtocolConstants.SEND_TO_ALL);
while(itr.hasNext()) {
ch.addItem(itr.next().toString());
}
mess = comm.getMessage();
jt.append(mess + "\n");
}//if
jt.setEditable(false);
}