powered by Jive Software

Accept user's adding request

I am in the case of an asynchronous web application using Smack API.

For a particular user, I managed to get all RosterEntries that are willing to become part of his list.

Unfortunately i could not find anywhere how I can set those RosterEntries status to ‘both’ when my user accepts it.

I tried :

RosterPacket.Item p = new RosterPacket.Item(user, name);

p.setItemType(RosterPacket.ItemType.both);

But then I don’t know how to send this request to my Jabber server!

Have a look at Roster.SubscriptionMode for automatically accepting or denieing subscription requests from others.

To use event listener model, see interface RosterListener.

To deal with request packets, something like:

if (presence.getType() == Presence.Type.subscribe) {
            // send subscription deny packet
            Presence response = new Presence(Presence.Type.unsubscribe);
            response.setTo(presence.getFrom());
            connection.sendPacket(response);
        }