1

I am currently building an chat application for android.

XMPP Server: MongooseIM.

XMPP Client: Smack 4.1.5.

Currently the logged in user keeps getting presence updates from his roaster buddies. I would like to receive these presence updates only when the application is open and block them when the application is closed. Is there a way to achieve this behavior? I have tried using privacy list but with no luck.

This is what i have tried so far.

        PrivacyListManager privacyManager = PrivacyListManager.getInstanceFor(mXMPPConnection);
        ArrayList privacyItems = new ArrayList();
        PrivacyItem item = new PrivacyItem(PrivacyItem.Type.subscription, "to", false, 1);
        item.setFilterPresenceIn(true);
        privacyItems.add(item);
        privacyManager.createPrivacyList("subscription", privacyItems);
Mithun Raman
  • 309
  • 4
  • 13
  • Without modifying the server routing strategies (at the source code level) it's not possible otherwise than by using privacy lists. [Routing of presence stanzas is specified by RFC-6121](https://tools.ietf.org/html/rfc6121#section-8.5.2.1.2). Why didn't privacy lists work for you? – erszcz Nov 29 '15 at 12:14
  • Privacy lists should have worked for me. According to smack documentation the 'PrivacyItem' class helps in 'Allowing or blocking inbound presence notifications.' Maybe am not using the class in the expected way. Its best if i attach a code snippet. Please do have look if you have worked on smack before. – Mithun Raman Dec 02 '15 at 06:29

1 Answers1

0

I assume that you want to stay connected to receive message but want to limit the presence traffic.

ejabberd supports XEP-0352 Client State Indication, which does exactly this. When going to background switch your client to inactive mode and presence update will not be send. When going back to foreground, switch CSI state to active and you will receive the relevant presence update, optimised by removing redundant obsolete presence informations.

You can check ejabberd documentation: mod_client_state

Mickaël Rémond
  • 9,035
  • 1
  • 24
  • 44