Sin*_*ngh 0 xmpp flow openfire ios xmppframework
我正在使用xmpp框架来开发使用openfire服务器的聊天应用程序.用户使用In Band帐户注册在服务器上注册.但我无法理解如何将用户添加到另一个用户的焙烧器列表中.应用程序是否必须获取在服务器上注册的所有用户,以便使用该应用程序的用户可以发送伙伴请求或当任何用户联机时,服务器必须将其广播给其他用户.我在流程中遇到困难.请帮帮我.
有两种方法可以做到这一点.
作为搜索的响应,您可以获得一个jids列表,您必须从中选择一个.现在再次有两个选项可以在您的名单列表中添加该jid
安装用户服务插件并使用openfire提供的add roster api.
从app如下
Run Code Online (Sandbox Code Playgroud)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];
}
Run Code Online (Sandbox Code Playgroud)
这个列出了iq用于各种目的.
PS:修改openfire ip和port后,与openfire的链接将起作用
| 归档时间: |
|
| 查看次数: |
168 次 |
| 最近记录: |