XMPPFarmework我们openfire
如何在iOS中获取XMPP聊天室列表? 任何人请告诉我一个解决这个问题的方法。谢谢!
答案 0 :(得分:1)
以下代码在连接到ejabberd
上的Amazon EC2
服务器时适用于我们,并希望它也适用于Openfire
。
- (void) getChatRooms:(XMPPStream *)stream
{
NSString* server = @"conference.myserver.com";
XMPPJID *servrJID = [XMPPJID jidWithString:server];
XMPPIQ *iq = [XMPPIQ iqWithType:@"get" to:servrJID];
[iq addAttributeWithName:@"id" stringValue:@"chatroom_list"];
[iq addAttributeWithName:@"from" stringValue:[stream myJID].full];
NSXMLElement *query = [NSXMLElement elementWithName:@"query"];
[query addAttributeWithName:@"xmlns" stringValue:@"http://jabber.org/protocol/disco#items"];
[iq addChild:query];
[firstStream sendElement:iq];
}
- (BOOL)xmppStream:(XMPPStream *)sender didReceiveIQ:(XMPPIQ *)iq
{
DDLogVerbose(@"%@", [iq description]);
}