powered by Jive Software

How to remove packet listeners

Hi guys,

I need to replace the http://jabber.org/protocol/disco#info packet management, coded in ServiceDiscoveryManager .

How I may do that? Is it possibile to implement a way to remove a PacketListener without the instance reference (XMPPConnection.removeListener(listener))?

The easy way will be adding an getID() method in PacketListener interface, so it’s possibile to removeListenerByID(String id) putting flexibility in Smack library.

What do you suggest for?

Tnx

You can register your own service discovery code using the Smack configuration file: “smack-config.xml”. This is the file that smack uses to load various core startup classes. Here is the section that you should look at:

You can replace the default service discovery manager class with your own class by changing the first entry.

Chris

Hey Giancarlo,

I’m curious…why is it that you need to replace the service discovery manager?

Regards,

– Gato

I tried to remove it from xml configuration but smack throw NullpointerException in XHTMLManager.

I removed also XHTMLManager and i catched an other NullpointerException in MultiUserChat:

java.lang.NullPointerException

  • at org.jivesoftware.smackx.muc.MultiUserChat$1.connectionCreated(MultiUserChat.jav a:84)+

I can’t no longer disable startup classes because I need MultiUserChat.

I’m wondering why configure startupClasses when the same classes are hardcoded everywhere.

My purpose is to replace disco#info response, with a custom jabber:x:data response.

How i may do that?

Thanks.

As a matter of clarification: Smack gives us troubles while trying to do stuff as described in http://www.xmpp.org/extensions/xep-0128.html

Hi all,

In PacketReader there is:

public void addPacketListener(PacketListener packetListener, PacketFilter packetFilter)

could you add a similar method with an ID for such listener?

public void addPacketListener(String id, PacketListener packetListener, PacketFilter packetFilter)

so we may remove the listener everywhere without object reference

public void removePacketListener(String id)

Thanks very much!

Can’t we have easy XEP-0128 support by adding a few lines like these to the processPacket() method of the PacketListener that generates responses to disco#info queries in ServiceDiscovery Manager?

if (infoExtension != null) {
  response.addExtension(infoExtension);
}

If we define infoExtension to be a field of type DataForm, and define a getter and setter, we should be done.

As far as I can see, this enables you to fully modify the response that Smack generates to disco#info queries.

For future reference: Daniel made this modification to the Smack source. I guess it’ll be available in the next release (3.0.5?).