Get PEP event using asmack

I’ve been trying to listen for PEP event from my server using asmack. I modify the avatar event publish event a little bit on my server side. My android client didn’t show the packet on the debugger. I’m using asmack library from https://github.com/Flowdalic/asmack/

<message from='jenggotz@192.168.202.121' to='jenggotz@192.168.202.121/2346608911361516490425217' type='headline'>

    <event xmlns='[http://jabber.org/protocol/pubsub#event](http://jabber.org/protocol/pubsub#event)'>

<items node='urn:xmpp:avatar:metadata'>

<item id='111f4b3c50d7b0df729d299bc6f8e9ef9066971f'>

<metadata xmlns='my:avatar:metadata'>0,0,0</metadata>

</item>

</items>

</event>

    <addresses xmlns='[http://jabber.org/protocol/address](http://jabber.org/protocol/address)'>

<address type='replyto' jid='jenggotz@192.168.202.121/2346608911361516490425217'/>

</addresses>

</message>

I’ve registered the provider for the event before connecting.

ProviderManager pm = ProviderManager.getInstance(); PEPProvider prov = new AwawaProvider();
prov.registerPEPParserExtension("urn:xmpp:avatar:metadata",new AvatarProvider());
pm.addExtensionProvider("event","http://jabber.org/protocol/pubsub#event",prov);

AwawaProvider is just an extension of PEPProvider, but I call android logging function on parseExtension.

public class AwawaProvider extends PEPProvider {
    @Override
    public PacketExtension parseExtension(XmlPullParser arg0) throws Exception {
        Log.e("PEPAWA", "AS");
        return super.parseExtension(arg0);
    }
}

But the log didn’t show it and my stanza didn’t shown on the debug log. So I conclude that I don’t register my provider in the right way. When I try to get ExtensionProviders on ProviderManager, it shows that I already put it in. Did I miss something in my code?

Thanks in advance

I don’t see any obvious errors in your code. Try attaching a debugger and set breakpoints at appropriate positions to find the problem.

Edit: On a second thought: Could it be that there is already a provider registered for that element that takes precedence?

First of all, thanks for continuing the asmack project. When I call

pm.getExtensionProvider("event", "http://jabber.org/protocol/pubsub#event");

it return my provider, so I think it already registered for PEP event. When I try to register a pubsub event, I can receive it (it shows on debug log). But somehow, I can’t get any PEP event using PEPProvider. I’ve been trying to understand the asmack source code, is there any way I can intercept unparsed XML received by my client? I’ve tried watching PacketParserUtils.parseMessage function, but my packet didn’t get received. Although it was received on Pidgin.

You cannot use PEP and pubsub, they have a conflict with regards to providers. (SMACK-416)

Although I haven’t tried this, in theory you may be able to use the pubsub API instead. The trick would be to set the “to” address when creating the pubsub manager to the publishers JID. PEP is pretty much just a subset of the pubsub functionality with more restrictions in place as to who can publish.

new PubsubManager(connection, "jenggotz@my.server.com");

If you try it and this works, please let us know

It works!

For it to work I have to register the providers for the pubsub and then subcribing to the friends node using that method. Thats why to get all of my roster PEP event, I have to register and subscribe to each one of their node.

Thank you Flow and rcollier