public void disconnect() {
        try {
            if (socket == null || socket.isClosed()) {
                return;
            } else {
                FileMessage m = new FileMessage("logout", ServerAction.NONE, null, messageCounter++);
                //output.writeObject(m);
                output.writeObject(securityManager.encryptMessage(m));
                socket.close();
            }
        } catch (Exception e) {
            System.err.println(e);
        }
    }