user724861
user724861

Reputation: 1074

cannot receive new created chats when adding custom IQProvider to Asmack

im using asmack-android-17-0.8.3 for my android project.

i have copied the asmack source into my project and i have also added my custom IQ provider at ConfigureProviderManager class like this:

other extensions and IQ providers...

// XEP-184 Message Delivery Receipts
    pm.addExtensionProvider("received", "urn:xmpp:receipts", new DeliveryReceipt.Provider());
    pm.addExtensionProvider("request", "urn:xmpp:receipts", new DeliveryReceipt.Provider());

    // XEP-0115 Entity Capabilities
    pm.addExtensionProvider("c", "http://jabber.org/protocol/caps", new CapsExtensionProvider());

    // XEP-0136
    pm.addIQProvider("list", "urn:xmpp:archive", new ListIQProvider());

as you can see, at the most bottom line, i have added IQProvider to support archiving in XEP-0136!

now, when i add this, i can get the archived chat data to my iq provider, but unfortunately at the same time it also make my client unable to receive new chats through the ChatManager!

is this still bug in asmack? what is the best way to add my custom iqprovider? please give me suggestion how to solve this. thanks!

Upvotes: 3

Views: 426

Answers (1)

ClerkMaxwell
ClerkMaxwell

Reputation: 11

Did you see this sentence from docs “Parse the IQ sub-document and create an IQ instance. Each IQ must have a single child element. At the beginning of the method call, the xml parser will be positioned at the opening tag of the IQ child element. At the end of the method call, the parser must be positioned on the closing tag of the child element.”?

Maybe you should write your code like the smack built-in provider MUCAdminProvider:

boolean done = false;
while (!done) {
        int eventType = parser.next();
        if (eventType == XmlPullParser.START_TAG) {
            if (parser.getName().equals("actor")) {
                item.setActor(parser.getAttributeValue("", "jid"));
            }
            if (parser.getName().equals("reason")) {
                item.setReason(parser.nextText());
            }
        }
        else if (eventType == XmlPullParser.END_TAG) {
            if (parser.getName().equals("item")) {
                done = true;
            }
        }
    }

Upvotes: 1

Related Questions