zoukankan      html  css  js  c++  java
  • IOS Xmpp的Iq发送和解析之请求讨论组成员

    #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];
                }
    
            }
        }
        
    }
  • 相关阅读:
    [Project Euler] 来做欧拉项目练习题吧: 题目002(转)
    [Project Euler] 欧拉项目练习题001(转)
    Linux wc 结合cat命令统计代码行数
    mysql:主键和索引的区别
    一些常用的SQL语句
    mysql 性能优化方案
    修改mysql用户密码
    Ruby on Rails,创建开发用的MYSQL数据库
    mysql数据库中分区的概念
    Rails 数据库操作
  • 原文地址:https://www.cnblogs.com/joesen/p/3559516.html
Copyright © 2011-2022 走看看