How to build a jabber client using libstrophe

限于喜欢 提交于 2019-12-11 11:46:43

问题


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?


回答1:


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


来源:https://stackoverflow.com/questions/11277844/how-to-build-a-jabber-client-using-libstrophe

易学教程内所有资源均来自网络或用户发布的内容,如有违反法律规定的内容欢迎反馈
该文章没有解决你所遇到的问题?点击提问,说说你的问题,让更多的人一起探讨吧!