I use this code to query server directly, but I'm not sure that is the best way.
XMPPIQ *iq = [[XMPPIQ alloc] initWithType:@"get"];
NSString* conferenceHost = [NSString stringWithFormat:@"conference.%@", _xmppStream.hostName];
[iq addAttributeWithName:@"from" stringValue:conferenceHost];
[iq addAttributeWithName:@"to" stringValue:_host];
DDXMLElement *query = [DDXMLElement elementWithName:@"query" xmlns:@"http://jabber.org/protocol/disco#items"];
[iq addChild:query];
[_xmppStream sendElement:iq];
Hope this help someone.
By the way, if you adopt this solution, then you have to do some parse in delegate method:
- (BOOL)xmppStream:(XMPPStream *)sender didReceiveIQ:(XMPPIQ *)iq {
}
I thing the best way is to parse method once the connection has started:
- (void)xmppStream:(XMPPStream *)sender didReceivePresence:(XMPPPresence *)presence {
/* parse */
}
Then you check
[[sender] from] domain]
if contains "conference." then you can think that sender is a room and finally you can add to NSMutableArray, for instance.
Also when a new room will be created, didReceivePresence will be called, so parser will add the new room.
So, you have:
NSMutableArray* rooms;
Your method will be:
-(NSMutableArray*)getRooms {
return _rooms;
}