5
votes

I am developing a chat application for Android using asmack. The connection is getting established and I'm able to login also. I've added listener for IQ packets and that is working fine. I have added listener for Presence packets also, here is my code:

PacketTypeFilter presenceFilter=new PacketTypeFilter(Presence.class);

connection.addPacketListener(new PacketListener() {
    public void processPacket(Packet packet) {
        Presence presence = (Presence)packet;

        Log.d("test1","Presence packet came :From:"+presence.getFrom()+",Packet ID:"+presence.getPacketID()+",Priority:"+presence.getPriority()+",To:"+presence.getTo()
                            +",Exn:"+presence.toXML());

        if (presence.getType() == Presence.Type.available) {
             Log.d("test1","User available");
        }
        else if (presence.getType() == Presence.Type.unavailable) {
                        Log.d("test1","User not available");
        }
    }
}, presenceFilter);

My problem is, this listener is never getting called for any incoming Presence packets. It's working for outgoing ones. I can't use Roster for handling presence as our server is using some Intelligent Routing Service for handling user availability. Am I doing anything wrong here? Any input will be helpful.

1

1 Answers

-2
votes

If you can't use roster then are you sure that any presence is being sent to this client in the first place?

Is the user that the client is signed in with on the roster of other users on the network?

Have you tested explicitly sending a presence packet to the client using a client where you can edit the raw xml?