I know that this question has been asked before, but only a partial response has been given by mschonaker here. On my website, user can add people to their roster, then the buddy has to accept and finally they are connected. The first person (user a) use the famous
roster.createEntry(jid, name, groups);
which works and add an entry in his roster, but then I am a bit confused to what to do:
how do I receive the request on the other end? I tried implementing a PacketListener, override processPacket() and check for packet which types are Presence.Type.subscribe or Presence.Type.subscribed, but it appears that it is only triggered for the user a, but not the one that should listen for subscriptions- user b.
then, I have another function that can lookup all requests at login, so if I login again I will see the request, but how do I accept it? at first, I thought that the user b should also add user a in his roster by
roster.createEntry(jid, name, groups);
but that didn't work and nothing was happening. I also tried to do
Presence subscribed = new Presence(Presence.Type.subscribed);
subscribed.setTo(jid);
xMPPConnection.sendPacket(subscribed);
but didn't work either. I'm sure there must be a good and simple way to do it, but I haven't found it so far anywhere, and trying one thing at a time gave me too many headaches. Does anyone know the correct flow for this? thanks in advance!