@Override
    public void closeVirtualConnection(@Nullable final StreamError error)
    {
        try {
            if (error != null) {
                deliverRawText0(error.toXML());
            }

            final String closeElement;
            if (STREAM_SUBSTITUTION_ENABLED.getValue()) {
                closeElement = "</stream:stream>";
            } else {
                closeElement = "<" + WebSocketClientStanzaHandler.STREAM_FOOTER + " xmlns='"+WebSocketClientStanzaHandler.FRAMING_NAMESPACE+"'/>";
            }
            deliverRawText0(closeElement);
        } finally {
            socket.getWsSession().close();
        }
    }
Following the conventions of the BOSH implementation, this class extends {@link VirtualConnection}
and delegates the expected XMPP connection behaviors to the corresponding {@link WebSocketClientConnectionHandler}.
xmppserver/src/main/java/org/jivesoftware/openfire/websocket/WebSocketConnection.java