@Override
    public void closeVirtualConnection(@Nullable final StreamError error) {
        // Figure out who requested the connection to be closed
        StreamID streamID = session.getStreamID();
        if (multiplexerManager.getClientSession(connectionManagerName, streamID) == null) {
            // Client or Connection manager requested to close the session
            // Do nothing since it has already been removed and closed
        }
        else {
            ConnectionMultiplexerSession multiplexerSession =
                    multiplexerManager.getMultiplexerSession(connectionManagerName,streamID);
            if (multiplexerSession != null) {
                // Server requested to close the client session so let the connection manager
                // know that he has to finish the client session
                IQ closeRequest = new IQ(IQ.Type.set);
                closeRequest.setFrom(serverName);
                closeRequest.setTo(connectionManagerName);
                Element child = closeRequest.setChildElement("session",
                        "http://jabber.org/protocol/connectionmanager");
                child.addAttribute("id", streamID.getID());
                child.addElement("close");
                if (error != null) {
                    // Note that this is ignored by all Connection Manager implementations at the time of writing.
                    child.add(error.getElement());
                }
                multiplexerSession.process(closeRequest);
            }
        }
    }
If the Connection Manager or the Client requested to close the connection then just do
nothing. But if the server originated the request to close the connection then we need
to send to the Connection Manager a packet letting him know that the Client Session needs
to be terminated.

@param error If non-null, this error will be sent to the peer before the connection is disconnected.
xmppserver/src/main/java/org/jivesoftware/openfire/multiplex/ClientSessionConnection.java