日期:2014-05-20 浏览次数:20763 次
//在此处完成消息的接受和转发,而且应该是一个一直在监听的状态。
public void run(){
while(true){
try {
System.out.println(ManageServerConClientThreadTable.table);
ObjectInputStream mesgFromClient = new ObjectInputStream(socket.getInputStream());
Message mesg = (Message)mesgFromClient.readObject();
System.out.print(mesg.getSender() + "对" + mesg.getReciever() + "说:" + mesg.getContents() + "\n");
System.out.println(ManageServerConClientThreadTable.getServerConClientThread(mesg.getSender()));
System.out.println(ManageServerConClientThreadTable.getServerConClientThread(mesg.getReciever()));
System.out.println(ManageServerConClientThreadTable.table);
if(ManageServerConClientThreadTable.table.containsKey(mesg.getReciever())){
System.out.println("存在");
}
ServerConClientThread scc = ManageServerConClientThreadTable.getServerConClientThread(mesg.getReciever());
if(scc == null){
System.out.println("scc为空");
}
ObjectOutputStream mesgToClient = new ObjectOutputStream(scc.socket.getOutputStream());
mesgToClient.writeObject(mesg);
}
catch (Exception e) {
// TODO Auto-generated catch block
e.printStackTrace();
}
}