Smack roster listeners..under the hood

I am developing an android client for an XMPP server.

The app is expected to have extended periods of user inactivity, where updated roster is not required.

However, the user should still be able to receive notifications of chat invites.

My question is:

  1. Is it possible to register and de-register a listener exclusively for roster updates?

The idea here is to avoid the overhead of maintaining the roster when its not required.

I know Smack API provides a ‘Roster Listener’ for this purpose.

But how is this actually implemented? Does the client create and maintain one TCP connection with the server over which it sends and receives all XML stanzas?

If so, does deregistering the roster listener stop roster update messages from coming in though this channel?

  1. Now, assuming we deregistered the roster listener when the app paused.

We will register again when the app resumes.

How will we get the latest presence information of all contacts in the roster?

Is there any API that returns the presence information of all contacts in roster?

I am quite new to the XMPP domain. I am going through RFCs 6121 and 6120.

Some inputs from experts will help to make sense of it all!



It sounds like you’d want to use XEP-352: Client State Indication for this. Unregistering the listener doesn’t help at all since it does not prevent the server from sending roster/presence changes. This is what you want to avoid when the mobile client is 'inactive.