带内帐户注册后的内容

Sin*_*ngh 0 xmpp flow openfire ios xmppframework

我正在使用xmpp框架来开发使用openfire服务器的聊天应用程序.用户使用In Band帐户注册在服务器上注册.但我无法理解如何将用户添加到另一个用户的焙烧器列表中.应用程序是否必须获取在服务器上注册的所有用户,以便使用该应用程序的用户可以发送伙伴请求或当任何用户联机时,服务器必须将其广播给其他用户.我在流程中遇到困难.请帮帮我.

Div*_*ert 5

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

  1. 在服务器上拥有用户数据库,您可以在服务器上获取所有用户.
  2. 使用openfire的搜索API.如果您没有使用任何Web服务,则可以实现xep-0055

作为搜索的响应,您可以获得一个jids列表,您必须从中选择一个.现在再次有两个选项可以在您的名单列表中添加该jid

  1. 安装用户服务插件并使用openfire提供的add roster api.

  2. 从app如下

XMPPJID *newBuddy = [XMPPJID jidWithString:@"jid"];
[xmppRoster addUser:newBuddy withNickname:nil];
Run Code Online (Sandbox Code Playgroud)

其他用户将通过在线获取

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];
}
Run Code Online (Sandbox Code Playgroud)

有关详细信息,请参阅此链接

这个列出了iq用于各种目的.

PS:修改openfire ip和port后,与openfire的链接将起作用