powered by Jive Software

Cannot get packet extension using smark api

Anybody can help me ?

i tryed many times but just can’t get the packet PacketExtension

the raw data i received is:

no

and i use packet listener to receive the packet and print like this:

mising the element:

no

i have search the problem and found that i did not provide a PacketExtensionProvider, so i implement the interface PacketExtensionProvider and PacketExtension and add to the provider manager:

ProviderManager.getInstance().addIQProvider(GiftExtention.ELEMENT_NAME, GiftExtention.NAMESPACE, new IqProvider());

but still can’t get the extention!

and i then read the document api org.jivesoftware.smack.provider Class ProviderManager,it says like this:

When an extension provider is not registered for an element name and namespace combination, Smack will store all top-level elements of the sub-packet in DefaultPacketExtension object and then attach it to the packet.

so i use:

xmppConnection.addPacketListener(new PacketListener() {

public void processPacket(Packet packet)

{

System.out.println("process received Packet: "+packet.toXML());

Collection packetExtensions = packet.getExtensions();

for(PacketExtension packetExtension:packetExtensions){

System.out.println(packetExtension.toXML());

}

}

}, null);

to print all the extentions,but i still can’t get the element.

so iam there aksing for help, can someone help me with this?

i finally got this problem,it is because i should use iqprovider not the packetextentionprovider