Specify packet id using pubsub extension

Hi

Is there a way to specify the packet id while using the pubsub extension library for publish requests? From our testing and looking at the source code it seems like this has been abstracted away from the user and the smack library is autogenerating the packet ids.

Thanks,

Conrad

I am afraid that was an oversight on my part. I will log an issue for it.

SMACK-313

Thanks for the response, once this issue has been logged, is there a timeframe associated with it such that the functionality will be available?

Not really, but I have thought about it and I think I can fix it pretty easily. I will post it to this thread when the issue is resolved.

Great, thanks for your help on this!

Well, after coding a solution for this, I came across the realization that it was a waste of time. You can already do what you want by creating your own PacketInterceptor and registering it with the Connection.

Thanks for the response.

I took a look at the PacketInterceptor and that definitely can be used to inject the packet id into outgoing packets. I guess the issue I’m facing would be how to identify which outgoing requests are publish requests so that I can inject a unique string into the packetId so that in my PacketFilter for the PacketListener for incoming xmpp traffic, I can easily filter based on the packet id which contains some prefix like “publish-”.

Do you have a recommendation on how to accomplish that? Would the best way be to code the PacketFilter for the PacketInterceptor to look for packets that contain the “publish” xml element?

Well, the simplest way would be to call Node.addPacketListener() and skip the direct packet handling altogether.

If this is not adequate for your particular use case, you can look at the code in the Node class under this method to see how to filter. I have a Node.EventContentFilter created that does what you are looking for, which is basically checking the namespace is correct and that the items and item elements are present in the message. I don’t see any need to set a specific packet id to resolve this problem.