Locoo Yi
Locoo Yi

Reputation: 13

XMPPFarmework How to obtain XMPP chat room list in iOS?

XMPPFarmework us openfire

How to obtain XMPP chat room list in iOS ? Anyone please show me a way to solve out this.Thanks!

Upvotes: 0

Views: 1092

Answers (1)

danfelabs
danfelabs

Reputation: 1893

Below code works for us when connected to an ejabberd server on Amazon EC2 and hope it should work for Openfire too.

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

Upvotes: 1

Related Questions