iOS如何从xmpp

时间:2016-12-10 11:09:36

标签: ios xmpp

我在我的iOS应用程序中集成了XMPP聊天服务器。请帮助我有没有办法从焙烧炉获取用户列表?  我使用下面的代码仍然没有回应。 。

- (void)getAllRegisteredUsers {

NSError *error = [[NSError alloc] init];
NSXMLElement *query = [[NSXMLElement alloc] initWithXMLString:@"<query xmlns='http://jabber.org/protocol/disco#items' node='all users'/>"
                                                        error:&error];
XMPPIQ *iq = [XMPPIQ iqWithType:@"get"
                             to:[XMPPJID jidWithString:@"DOMAIN"]
                      elementID:[xmppStream generateUUID] child:query];
[xmppStream sendElement:iq];
}

- (BOOL)xmppStream:(XMPPStream *)sender didReceiveIQ:(XMPPIQ *)iq
{ 
 NSXMLElement *queryElement = [iq elementForName: @"query" xmlns: @"http://jabber.org/protocol/disco#items"];

if (queryElement) {
    NSArray *itemElements = [queryElement elementsForName: @"item"];
    NSMutableArray *mArray = [[NSMutableArray alloc] init];
    for (int i=0; i<[itemElements count]; i++) {

        NSString *jid=[[[itemElements objectAtIndex:i] attributeForName:@"jid"] stringValue];
        [mArray addObject:jid];
    }
}

0 个答案:

没有答案