XMPPFarmework如何在iOS中获取XMPP聊天室列表?

时间:2015-03-18 14:17:08

标签: xmpp xmppframework

XMPPFarmework我们openfire

如何在iOS中获取XMPP聊天室列表? 任何人请告诉我一个解决这个问题的方法。谢谢!

1 个答案:

答案 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]);    
}