Custom Stream Management Callbacks

Hi all, I’m happily using Smack 4.1alpha3 for an Android project but I’m running into an issue with stream management.

The XMPP server I’m working with requires some custom handling of stream management acks, but there doesn’t seem to be a way in Smack to register a PacketListener on that packet type.

Is this something that can be added? I’m happy to pitch in and write a patch, but I want to ensure I move in the right direction with the full blessing of the community.

My approach would be to use the existing packet listener/collector/filter infrastructure, so have AckAnswer, AckRequest etc extend Packet (possible?), and then call processPacket() after processHandledCount() in the big switch statement within parsePackets().

Does that seem like a reasonable thing to do?

Is this something that can be added?
No, because if we do so, then we would be put Smack in a position to include all sorts of code for non-standard compliant specifications (like custom message types (which is something you should not define)). I follow strict policy to not include code that deals with unspecified, in terms of RFCs and XEPs, behavior. Smack is build against a specification, not an implementation.

I also think that it’s not a good idea to extend packet listener/collector/filter to non-Stanza elements. Everything that is not a stanza is used as stream control feature of some sort. Users using the library should not have to deal with that, it’s something the library tries to abstract away from the user.

I’m curious what that kind of custom handling of the XMPP server tries to achieve. Could you elaborate that?

Although XMPP includes the term “extensible” there are certain limitations how it should be extended. See also XEP-143.

My blind guess is that he refers to something like this:

stream:features

    <compression xmlns="[http://jabber.org/features/compress](http://jabber.org/features/compress)">

zlib

** **

** **

which seems to be a proprietary protocol used by process-one.net, probably similar to XEP-0198.

I anticipated this would be your answer, but let me follow up with a bit more explanation.

I am not suggesting Smack should implement anything that’s nonstandard in terms of the XMPP RFC and extensions. I am merely suggesting that it would be useful if there were hooks on more packet types.

Everything that is not a stanza is used as stream control feature of some sort. Users using the library should not have to deal with that

I agree that users should not have to deal with stream control features. But some of us want/need to.

In particular I would like to show a user of my application whether a sent message was received and processed and acked by the server. I don’t currently have a good way to do this since there is no callback interface for server acks in Smack.

Now you might say that I’m attempting to misuse stream management in a way that it wasn’t designed for. If that’s the case, what feature of XMPP/Smack should I be using to show a user whether their attempt to send a message was successful or failed?

I don’t currently have a good way to do this since there is no callback interface for server acks in Smack.
There is such a callback for XEP-198 acks: XMPPTCPConnection.addStanzaAcknowledgedListener(PacketListener) and addIdStanzaAcknowledgedListener(String, PacketListener).

Thanks, I’ll look into that API.