美文网首页
IOS Xmpp的Iq发送和解析之请求讨论组成员

IOS Xmpp的Iq发送和解析之请求讨论组成员

作者: 06f43b0b52f7 | 来源:发表于2017-08-19 13:54 被阅读30次

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

      }

    }

    相关文章

      网友评论

          本文标题:IOS Xmpp的Iq发送和解析之请求讨论组成员

          本文链接:https://www.haomeiwen.com/subject/zxetdxtx.html