zoukankan      html  css  js  c++  java
  • IOS Xmpp 创建固定房间

    XMPPRoom *room;
    
     // 初始化房间
     XMPPRoomCoreDataStorage *rosterstorage = [[XMPPRoomCoreDataStorage alloc] init];
        if (rosterstorage==nil) {
            NSLog(@"nil");
            rosterstorage = [[XMPPRoomCoreDataStorage alloc] init];
        }
        roomJID = [XMPPJID jidWithString:roomName];
        room = [[XMPPRoom alloc] initWithRoomStorage:rosterstorage jid:roomJID
                                                 dispatchQueue:dispatch_get_main_queue()];
        
        [room activate:[[XMPPManager sharedManager] xmppStream]];
       
        // 在聊天是显示的昵称
        [room joinRoomUsingNickname:jid history:nil];
        
        [room fetchConfigurationForm];
    
        [room addDelegate:self delegateQueue:dispatch_get_main_queue()];
    
    #pragma mark 配置房间为永久房间
    -(void)sendDefaultRoomConfig
    {
        
        NSXMLElement *x = [NSXMLElement elementWithName:@"x" xmlns:@"jabber:x:data"];
        
        NSXMLElement *field = [NSXMLElement elementWithName:@"field"];
        NSXMLElement *value = [NSXMLElement elementWithName:@"value"];
        
        NSXMLElement *fieldowners = [NSXMLElement elementWithName:@"field"];
        NSXMLElement *valueowners = [NSXMLElement elementWithName:@"value"];
        
        
        [field addAttributeWithName:@"var" stringValue:@"muc#roomconfig_persistentroom"];  // 永久属性
        [fieldowners addAttributeWithName:@"var" stringValue:@"muc#roomconfig_roomowners"];  // 谁创建的房间

    [field addAttributeWithName:@"type" stringValue:@"boolean"]; [fieldowners addAttributeWithName:@"type" stringValue:@"jid-multi"]; [value setStringValue:@"1"]; [valueowners setStringValue:myJid]; //创建者的Jid [x addChild:field]; [x addChild:fieldowners]; [field addChild:value]; [fieldowners addChild:valueowners]; [room configureRoomUsingOptions:x]; } // 房间创建成功后在配置永久属性 #pragma mark - 创建讨论组成功回调 - (void)xmppRoomDidCreate:(XMPPRoom *)sender { [self sendDefaultRoomConfig]; }
  • 相关阅读:
    listview 优化
    重要博客网址
    bottombar——Fragment
    视频播放,,今日头条样式
    databinding
    Picasso
    22222222
    202004leetcode刷题记录
    批量下载邮箱中指定日期范围的附件
    有雾环境下的目标检测
  • 原文地址:https://www.cnblogs.com/joesen/p/3539527.html
Copyright © 2011-2022 走看看