powered by Jive Software

Smack PacketListener Not Running

I am trying to write a listener for a smack packet. What ends up happening is the listener sometimes just doesn’t get the packet and process it. Here is some of the code

`try {

XMPPMethods.getConnection().addPacketListener( new PacketListener() {
@Override
public synchronized void processPacket(Packet packet) {

if (packet.getPacketID().equals(lastCustomIQId)) {

android.os.Message msg = new android.os.Message();
msg.obj = privateData;
msg.what = XMPPMethods.ADD_CONTACT_RESULTS;
AddContact.addContactHandler.sendMessage(msg);
}
}
}, new PacketIDFilter(lastCustomIQId));`

Note that this IS inside of the doInBackground(string… params) part of an asynctask.

The packet is being sent using:

JIDIQ.setPacketID(lastCustomIQId); JIDIQ.setFrom(XMPPMethods.getCurrentUserFullUserName()); JIDIQ.setType(Type.GET); XMPPMethods.getConnection().sendPacket(JIDIQ);

This code all runs correctly MOST of the time. But sometimes the PacketListener just doesn’t receive the packet sent. Does anyone know why this wouldn’t receive the packet? Any knowledge of this subject would be greatly appreciated!