Search in sources :

Example 6 with SmackParsingException

use of org.jivesoftware.smack.parsing.SmackParsingException in project Smack by igniterealtime.

the class ModularXmppClientToServerConnection method parseAndProcessElement.

private void parseAndProcessElement(String element) {
    try {
        XmlPullParser parser = PacketParserUtils.getParserFor(element);
        // Skip the enclosing stream open what is guaranteed to be there.
        parser.next();
        XmlPullParser.Event event = parser.getEventType();
        outerloop: while (true) {
            switch(event) {
                case START_ELEMENT:
                    final String name = parser.getName();
                    // Note that we don't handle "stream" here as it's done in the splitter.
                    switch(name) {
                        case Message.ELEMENT:
                        case IQ.IQ_ELEMENT:
                        case Presence.ELEMENT:
                            try {
                                parseAndProcessStanza(parser);
                            } finally {
                            // TODO: Here would be the following stream management code.
                            // clientHandledStanzasCount = SMUtils.incrementHeight(clientHandledStanzasCount);
                            }
                            break;
                        case "error":
                            StreamError streamError = PacketParserUtils.parseStreamError(parser, null);
                            StreamErrorException streamErrorException = new StreamErrorException(streamError);
                            currentXmppException = streamErrorException;
                            notifyWaitingThreads();
                            throw streamErrorException;
                        case "features":
                            parseFeatures(parser);
                            afterFeaturesReceived();
                            break;
                        default:
                            parseAndProcessNonza(parser);
                            break;
                    }
                    break;
                case END_DOCUMENT:
                    break outerloop;
                // fall out
                default:
            }
            event = parser.next();
        }
    } catch (XmlPullParserException | IOException | InterruptedException | StreamErrorException | SmackParsingException e) {
        notifyConnectionError(e);
    }
}
Also used : StreamErrorException(org.jivesoftware.smack.XMPPException.StreamErrorException) StreamError(org.jivesoftware.smack.packet.StreamError) XmlPullParser(org.jivesoftware.smack.xml.XmlPullParser) XmlPullParserException(org.jivesoftware.smack.xml.XmlPullParserException) IOException(java.io.IOException) SmackParsingException(org.jivesoftware.smack.parsing.SmackParsingException)

Aggregations

SmackParsingException (org.jivesoftware.smack.parsing.SmackParsingException)6 IOException (java.io.IOException)3 XmlPullParserException (org.jivesoftware.smack.xml.XmlPullParserException)3 XmlEnvironment (org.jivesoftware.smack.packet.XmlEnvironment)2 XmlPullParser (org.jivesoftware.smack.xml.XmlPullParser)2 AbstractMultiFormField (org.jivesoftware.smackx.xdata.AbstractMultiFormField)2 AbstractSingleStringValueFormField (org.jivesoftware.smackx.xdata.AbstractSingleStringValueFormField)2 BooleanFormField (org.jivesoftware.smackx.xdata.BooleanFormField)2 FormField (org.jivesoftware.smackx.xdata.FormField)2 JidMultiFormField (org.jivesoftware.smackx.xdata.JidMultiFormField)2 JidSingleFormField (org.jivesoftware.smackx.xdata.JidSingleFormField)2 ListMultiFormField (org.jivesoftware.smackx.xdata.ListMultiFormField)2 ListSingleFormField (org.jivesoftware.smackx.xdata.ListSingleFormField)2 TextSingleFormField (org.jivesoftware.smackx.xdata.TextSingleFormField)2 ArrayList (java.util.ArrayList)1 QName (javax.xml.namespace.QName)1 StreamErrorException (org.jivesoftware.smack.XMPPException.StreamErrorException)1 Message (org.jivesoftware.smack.packet.Message)1 Presence (org.jivesoftware.smack.packet.Presence)1 PresenceBuilder (org.jivesoftware.smack.packet.PresenceBuilder)1