@Override public void run() { while (clientSocket != null) { // String StringMessage=null; Object objectMsg; Messages msg; try { CommonUtils.PrintMe("The server receive a Message from client"); objectMsg = in.readObject(); msg = (Messages) objectMsg; CommonUtils.PrintMe("the thread read a message from client" + msg.toString()); msg = this.decryptMsg(msg); CommonUtils.PrintMe("the message decrypted is:" + msg.getContent()); // StringMessage=msg.getContent(); } catch (IOException | ClassNotFoundException ex) { ex.printStackTrace(); TcpChatServer.disconnect(this); TcpChatServer.notifyChatRoom(); return; } if (objectMsg == null) { // the client leaved CommonUtils.PrintMe("warning-----------objectMsg is null"); TcpChatServer.disconnect(this); TcpChatServer.notifyChatRoom(); return; } if (msg.getMsgType() == Messages.MSG) { CommonUtils.PrintMe("~~~~~~~~~~~the user send a message"); // 这里转发信息,信息的处理要在这里进行 // #if Spamfilter super.FiltspamMsg(msg); // #endif msg = this.decryptMsg(msg); TcpChatServer.sendClients(msg); // send message to every clients System.out.println("@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@"); msg.printMsg(); System.out.println("@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@"); CommonUtils.PrintMe("the message sended to all clients:"); msg.printMsg(); } else if (msg.getMsgType() == Messages.QUIT) { CommonUtils.PrintMe("the user want to disconnect"); TcpChatServer.disconnect(this); TcpChatServer.notifyChatRoom(); } } // end while }