@Override
    protected void createSession(XmlPullParser xpp) throws XmlPullParserException, IOException {
        for (int eventType = xpp.getEventType(); eventType != XmlPullParser.START_TAG;) {
            eventType = xpp.next();
        }

        final String serverName = XMPPServer.getInstance().getServerInfo().getXMPPDomain();
        String host = xpp.getAttributeValue("", "to");

        try {
            // Check that the TO attribute of the stream header matches the server name or a valid
            // subdomain. If the value of the 'to' attribute is not valid then return a host-unknown
            // error and close the underlying connection.
            if (validateHost() && isHostUnknown(host)) {
                throw new StreamErrorException(StreamError.Condition.host_unknown, "Incorrect hostname in stream header: " + host);
            }

            if (!STREAM_HEADER.equals(xpp.getName())) {
                throw new StreamErrorException(StreamError.Condition.unsupported_stanza_type, "Incorrect stream header: " + xpp.getName());
            }

            // Validate the stream namespace (https://tools.ietf.org/html/rfc7395#section-3.3.2)
            if (!FRAMING_NAMESPACE.equals(xpp.getNamespace())) {
                throw new StreamErrorException(StreamError.Condition.invalid_namespace, "Invalid namespace in stream header: " + xpp.getNamespace());
            }

            // Create the correct session based on the sent namespace. At this point the server
            // may offer the client to encrypt the connection. If the client decides to encrypt
            // the connection then a <starttls> stanza should be received
            createSession(serverName, xpp, connection);
        }
        catch (final StreamErrorException ex) {
            Log.warn("Failed to create a session. Closing connection: {}", connection, ex);
            connection.deliverRawText(ex.getStreamError().toXML());
            connection.deliverRawText("<close xmlns='" + FRAMING_NAMESPACE + "'/>");
            connection.close();
        }
    }
A {@link org.jivesoftware.openfire.net.StanzaHandler} that is able to process the specific framing that is used by
clients connecting via websockets.

@author Guus der Kinderen, guus@goodbytes.nl
@see <a href="https://www.rfc-editor.org/rfc/rfc7395.html">RFC 7395:  An Extensible Messaging and Presence Protocol (XMPP) Subprotocol for WebSocket</a>
xmppserver/src/main/java/org/jivesoftware/openfire/websocket/WebSocketClientStanzaHandler.java