-1

I have Packetlistener in which can show presence changed from different resources. what I want that whenever a presence change from other resource it should resend a received presence packet but only one time. However, it keeps continuously sending packets.

        connection.addPacketListener(new PacketListener(){

        @Override
        public void processPacket(Packet presencePkt) {
             pres= ((Presence) presencePkt);

        switch(pres.getMode()){
            case available: 
                connection.sendPacket(pres);
            break;
            case dnd: 
                connection.sendPacket(pres);
            break;

            default :
                break;

        }


    }

}, new PacketTypeFilter(Presence.class));
Qaiser Mehmood
  • 975
  • 6
  • 21
  • 33

1 Answers1

1

If I interpret your code correctly, you simply resend a presence packet as-is, therefore sending the packet directly to yourself again. You receive that resent packet and don't know it's already been resent by you and send it again, and so on.

If you really want to resend a packet to yourself only once, you might want to assign an ID before resending it.

TomTasche
  • 5,448
  • 7
  • 41
  • 67