@SuppressWarnings("deprecation")  
    public synchronized boolean closeConnection() {  
        try {  
            listModel.removeAllElements();
            listmodel.removeAllElements();
            onLineUsers.clear();
            chatRooms.clear();
            objChatRooms.clear();
            frame.setTitle("Client");
            sendMessage("CLOSE");// 发送断开连接命令给服务器 
            messageThread.stop();// 停止接受消息线程  
            // 释放资源  
            if (reader != null) {  
                reader.close();  
            }  
            if (writer != null) {  
                writer.close();  
            }  
            if (socket != null) {  
                socket.close();  
            }  
            isConnected = false;  
            return true;  
        } catch (IOException e1) {  
            e1.printStackTrace();  
            isConnected = true;  
            return false;  
        }  
    }