XMPPFramework : can I determine the online/offline status of a user at all?

不问归期 提交于 2019-12-11 01:37:01

问题


How would I determine if a user is online/offline using XMPPFramework for iPhone?

I have their JID etc etc. Is there a way of requesting a presence or something?

Thank you.


回答1:


Have you checked out the source code of the XMPPFramework sample project?

If I remember correctly, this should be the relevant code snippet:

// Subscribe to the buddy's presence
// 
// <presence to="bareJID" type="subscribe"/>

NSXMLElement *presence = [NSXMLElement elementWithName:@"presence"];
[presence addAttributeWithName:@"to" stringValue:[jid bare]];
[presence addAttributeWithName:@"type" stringValue:@"subscribe"];

[xmppStream sendElement:presence];

And the callback your stream delegate gets should be

- (void)xmppStream:(XMPPStream *)sender didReceivePresence:(XMPPPresence *)presence;

I assume that you already have the xmmpframework source, if not, you can clone the repository here

hg clone https://xmppframework.googlecode.com/hg/ xmppframework

The sample projects are in the "Xcode" folder.



来源:https://stackoverflow.com/questions/4960037/xmppframework-can-i-determine-the-online-offline-status-of-a-user-at-all

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