2014-03-04 51 views
0

我使用xmpp框架开发使用openfire服务器的聊天应用程序。用户使用In Band帐户注册在服务器上注册。但我无法理解用户将如何添加到其他用户的烘焙器列表中。应用程序是否必须获取在服务器上注册的所有用户,以便使用该应用程序的用户可以发送好友请求。或者,当任何用户上线时,服务器必须将其广播给其他用户。我在流程中遇到困难。请帮助我。带内帐号注册后的内容

回答

5

有两种方法可以做到这一点。

  1. 拥有服务器上的用户数据库,您可以在服务器上获取服务器上的所有用户 。
  2. 使用Search api of openfire。如果你不使用任何 web服务,可以实现xep-0055

由于搜索的响应,你可以得到JID的列表,从那里你必须选择一个。 现在再次有两个选项添加JID通过的Openfire提供您的名单列表

  1. 安装用户服务插件,并使用add roster api

  2. 从应用程序如下

XMPPJID *newBuddy = [XMPPJID jidWithString:@"jid"]; 
[xmppRoster addUser:newBuddy withNickname:nil]; 

其他用户将通过存在

if([presenceType isEqualToString:@"subscribe"]) 
{ 
    NSXMLElement *presenceToRequest = [NSXMLElement elementWithName:@"presence"]; 
    [presenceToRequest addAttributeWithName:@"type" stringValue:@"subscribed"]; 
    [presenceToRequest addAttributeWithName:@"to" stringValue:[NSString stringWithFormat:@"%@", [presence fromStr]]]; 
    [presenceToRequest addAttributeWithName:@"from" stringValue:[NSString stringWithFormat:@"%@", [presence toStr]]]; 
    [[self xmppStream] sendElement:presenceToRequest]; 
} 

Refer this link for more info

这份名单出来IQ所使用FO得到它各种目的。

PS:修改openfire ip和端口后,与openfire的链接将工作