Question

I'm trying to make a simple Jabber client using the libstrophe library.

It's going fairly well so far, except for one thing for which I need some clarification.

Namely, how am I supposed to (continuously) know the status (i.e., Online/Offline) of contacts, so that I can display it to the user of my program? Similarly, how am I supposed to request the roster of the user?

I've looked at the roster.c example provided by libstrophe, but that only prints out the roster once. In a real application, I'll need to request/update this continuously, in order to show any new contacts the user added, etc., in the application.

So basically, I'm unclear on how to make sure that I always display the most current roster and most current statuses of people in my user's contact list.

Am I just supposed to request the roster at some predefined time interval, for example?

Was it helpful?

Solution

roster and presence are 2 different topics.

When you login you normally request the roster which you are doing already. When your contact lists changes during your session you get a roster push with the updated contact. This is an stanza. It doesn't matter if another logged in client manipulated the roster our your client.

The online state called presence of all your subscribed contact comes in with stanzas.

You have to setup handlers with xmpp_handler_add for

  1. Online state, presence stanzas
  2. Roster pushes, iq stanzas with query of namespace jabber:iq:roster
Licensed under: CC-BY-SA with attribution
Not affiliated with StackOverflow
scroll top