IGNORE: subscribe and roster


Here’'s what I am trying to do:

  1. I have the subscription mode set to MANUAL.

  2. I want to receive sub requests, see if they match an internal criteria and only if they do I want to okay them.

Here’'s my code snippet. How do I send out an OKAY message?


PacketFilter myFilter = new PacketFilter() {

public boolean accept(Packet packet) {

boolean ret = false;

if (packet instanceof Presence) {

if (((Presence)packet).getType().equals(Presence.Type.SUBSCRIBE)) {

ret = true;



return ret;



JabberMessenger.connection.addPacketListener(new PacketListener() {

public void processPacket(Packet arg0) {

//chk if user is enabled/in our roster

//send OK message to accept sub request

//?? what goes in here???


}, myFilter);

EDIT: Found the answer myself. I create a presence packet of type SUBSCRIBED

Message was edited by: bharatg