Android with Asmack - How do I fetch current presence information when I connect to XMPP?

StackOverflow https://stackoverflow.com/questions/22325616

  •  12-06-2023
  •  | 
  •  

سؤال

I have an asmack based client, I connect and authenticate, then I fetch a roster, to which I attach a listener and I set myself available.

The listener correctly picks up any changes to presence made after I connect, however I can't find a way of getting the current state of all the entries on my roster.

I tried sending a Presence.Type.subscribe packet, I tried using Roster#reload() and I've tried the following:

for (RosterEntry entry : mRoster.getEntries()) {
   Presence presence = mRoster.getPresence( entry.getUser() );
   ...
}

(If I log the presence object above, they all show as 'unavailable')

I've also tried mRoster.getPresence(handle) inside entriesUpdated when I get the callback from Roster#reload and separately when looping over Roster#getEntries, I get valid user id's but the presence mode is null and type is unavailable for every entry

Is there a way I can prompt the server to send me the current remote information?

هل كانت مفيدة؟

المحلول 2

I have solved this issue, it appears part of the example I followed to set up my configuration was incorrect.

Including the following setting in your ConnectionConfiguration will cause the issue:

config.setSendPresence(false);

After I removed this, initial presences were updated correctly

نصائح أخرى

What about

Roster.getEntries()

?

مرخصة بموجب: CC-BY-SA مع الإسناد
لا تنتمي إلى StackOverflow
scroll top