src/main/java/org/jivesoftware/smack/PacketReader.java
private void parsePackets(Thread thread) {
        try {
            while (!done) {
                if (reset) {
                    startStream();
                    LOGGER.debug("Started xmlstream...");
                    reset = false;
                    continue;
                }
                Element doc = innerReader.parseDocument().getRootElement();
                if (doc == null) {
                    connection.disconnect();
                    LOGGER.debug("End of xmlstream.");
                    continue;
                }
                Packet packet = null;
                LOGGER.debug("Processing packet " + doc.asXML());
                packet = parseFromPlugins(doc, packet);
                if (packet == null) {
                    packet = parseFromCore(doc);
                }
                if (packet != null) {
                    processPacket(packet);
                }
            }
        } catch (Exception e) {
            if (!done && !connection.isSocketClosed()) {
                connection.notifyConnectionError(e);
                if (!connection.isConnected()) {
                    releaseConnectionIDLock();
                }
            }
        }
    }
private void parsePackets(Thread thread) {
        try {
            while (!done) {
                if (reset) {
                    startStream();
                    LOGGER.debug("Started xmlstream...");
                    reset = false;
                    continue;
                }
                Element doc = innerReader.parseDocument().getRootElement();
                if (doc == null) {
                    connection.disconnect();
                    LOGGER.debug("End of xmlstream.");
                    continue;
                }
                Packet packet = null;
                LOGGER.debug("Processing packet " + doc.asXML());
                packet = parseFromPlugins(doc, packet);
                if (packet == null) {
                    packet = parseFromCore(doc);
                }
                if (packet != null) {
                    processPacket(packet);
                }
            }
        } catch (Exception e) {
            if (!done && !connection.isSocketClosed()) {
                connection.notifyConnectionError(e);
                if (!connection.isConnected()) {
                    releaseConnectionIDLock();
                }
            }
        }
    }
Parse top-level packets in order to process them further.

@param thread
the thread that is being used by the reader to parse incoming
packets.