0
votes

I would like to get all of my contacts presence and status information which they supplied to server before going offline. I found the below method to query one contact's presence information but what I want to do here is to query all of my contact's presence information at once. Because If I have 200 roster item, I dont want to make 200 requests. Is there any way to do something like this Or is there anyway to change this in the xmpp server(ejabberd) side

Thanks tolga

1

1 Answers

1
votes

Use Roster to get roster status & presence. Here is an example,

Roster roster = Roster.getInstanceFor(this.connection);
roster.addRosterListener(new RosterListener() {
    @Override
    public void entriesAdded(Collection<String> addresses) {
        // Notified on roster added
    }

    @Override
    public void entriesUpdated(Collection<String> addresses) {
        // Notified on roster updated
    }

    @Override
    public void entriesDeleted(Collection<String> addresses) {
        // Notified on roster deleted
    }

    @Override
    public void presenceChanged(Presence presence) {
        // Notified in roster status changed
        // You will get presences here
    }
});