IOS Xmpp的Iq发送和解析之请求讨论组成员
http://www.cnblogs.com/joesen/p/3559516.html
pragma mark - 获取讨论组成员
-
(void)getDiscussionMemberInfoWithSendIq:(discussionModel *)data
{NSXMLElement *iq = [NSXMLElement elementWithName:@"iq"];
NSXMLElement *getUsers = [NSXMLElement elementWithName:@"getUsers"];[iq addAttributeWithName:@"id" stringValue:@"SPUT4-6"];
[iq addAttributeWithName:@"type" stringValue:@"get"];
[iq addAttributeWithName:@"from" stringValue:[NSString stringWithFormat:@"%@",[xmppStream myJID]]];[getUsers addAttributeWithName:@"xmlns" stringValue:@"com:im:roominfo"];
[getUsers addAttributeWithName:@"roomId" stringValue:[Unity jidWithName:data.roomKey]];[iq addChild:getUsers];
[xmppStream sendElement:iq];
}
pragma mark - 解析讨论组成员
-
(void)analyticDiscussionMemberWithIq:(XMPPIQ *)iq
{
if ([@"result" isEqualToString:iq.type]) {
NSXMLElement *member = iq.childElement;
if ([@"mucinfo" isEqualToString:member.name])
{
NSMutableArray *memberArr = [[NSMutableArray alloc]init];
NSArray *items = [member children];
for (NSXMLElement *item in items) {
discussionInfoModel *disInfo = [[discussionInfoModel alloc]init];
disInfo.memberName = [item stringValue];
disInfo.memberId = [item attributeStringValueForName:@"jid"];
disInfo.memberPicUrl = [item attributeStringValueForName:@"headPhoto"];
[memberArr addObject:disInfo];
}if ([delegate respondsToSelector:@selector(passDiscussionMebmer:)]) { [delegate passDiscussionMebmer:memberArr]; } }
}
}