1
votes

I am using smack 4.1 now. All i want to reload/refresh roster after sending a presence and get the changes in new roster. For example

  1. I have an entry of user 'A' with type none and status null in Roster
  2. then i have sent an subscribe presence for above entry of user 'A'
  3. now i want to fire a reload and wait till roster not get refreshed(its different from Roster.reloadAndWait() method provided in smack)
  4. After roster refresh i would get entry of user 'A' as type=none and status=subscribe.

So my question here

  1. Is there a simple blocking call to reload fresh roster? According to my study roster.reload() would send an IQ to reload but it won't block the call till reload. reloadAndWait() method also does the same thing from 2nd and onward calls with the help of boolean isLoaded. reloadAndWait method would only block the call for first time if its not loaded(correct me if wrong).

  2. Is there any way to get a callback when roster reload operation completes(sync or async) in smack?

  3. Is it possible to make a request for reload of a single RosterEntry?

  4. Is it good practice to verify the impact of presence change through roster refresh?

Thanks for your valuable suggestion and answer

1

1 Answers

0
votes

The general approach is not to require the roster from server more than once during a session.

The expected workflow in XMPP is as follow:

  1. Request the roster at the start of the session. This is not mandatory but commonly done. See for reference RFC 6121 Retrieving Roster on Login
  2. Update your in memory roster state based on the roster change you perform. Not that you will receive roster changes confirmation no matter if this is your current session performing the change or another client logged in with same JID (Roster Set result or Roster Push).

Doing that, you will always have an in-memory representation of your roster which is up to date during your whole session. This is the workflow XMPP was designed for.