protected void initiateSession(String stanza, XMPPPacketReader reader) throws Exception
    {
        boolean initialStream = isStartOfStream(stanza);
        if (!initialStream) {
            // Ignore <?xml version="1.0"?>
            return;
        }
        // Found a stream:stream tag...
        if (!sessionCreated) {
            sessionCreated = true;
            MXParser parser = reader.getXPPParser();
            parser.setInput(new StringReader(stanza));
            createSession(parser);
        }
        else if (startedTLS) {
            MXParser parser = reader.getXPPParser();
            parser.setInput(new StringReader(stanza));
            tlsNegotiated(parser);
            startedTLS = false;
        }
        else if (startedSASL && saslStatus == SASLAuthentication.Status.authenticated) {
            startedSASL = false;
            saslSuccessful();
        }
        else if (waitingCompressionACK) {
            waitingCompressionACK = false;
            compressionSuccessful();
        }
    }
Creates a dedicated reader for a socket.

@param router     the router for sending packets that were read.
@param connection the connection being read.
xmppserver/src/main/java/org/jivesoftware/openfire/net/StanzaHandler.java