XMPP Group向所有用户显示空间

时间:2016-05-03 09:52:07

标签: ios objective-c xmpp xmppframework groupchat

在iOS上使用XMPP群聊。我能够使用以下代码

成功创建一个组
NSString *groupName=[NSString stringWithFormat:@"%@@conference.myserver.com",self.groupNameTxtFld.text];
  XMPPJID *roomJID = [XMPPJID jidWithString:groupName];
  self.xmppRoom = [[XMPPRoom alloc] initWithRoomStorage:[[self xmppSharedManager] roomStorage]
                                                    jid:roomJID
                                          dispatchQueue:dispatch_get_main_queue()];

  [self.xmppRoom activate:[self xmppSharedManager].xmppStream];
  [self.xmppRoom addDelegate:self
               delegateQueue:dispatch_get_main_queue()];

  [self.xmppRoom joinRoomUsingNickname:[self xmppSharedManager].xmppStream.myJID.user
                               history:nil
                              password:nil];

创建完成配置的组后。

- (void)xmppRoom:(XMPPRoom *)sender didFetchConfigurationForm:(NSXMLElement *)configForm
{
NSXMLElement *newConfig = [configForm copy];
NSArray *fields = [newConfig elementsForName:@"field"];

for (NSXMLElement *field in fields)
{
NSString *var = [field attributeStringValueForName:@"var"];
// Make Room Persistent

if ([var isEqualToString:@"muc#roomconfig_persistentroom"]) {
[field removeChildAtIndex:0];
[field addChild:[NSXMLElement elementWithName:@"value" stringValue:@"1"]];
}
}

[sender configureRoomUsingOptions:newConfig];

}

通过发送以下请求获取群组

 XMPPJID *servrJID = [XMPPJID jidWithString:@"conference.myserver.com"];
    XMPPIQ *iq = [XMPPIQ iqWithType:@"get" to:servrJID];
    [iq addAttributeWithName:@"from" stringValue:[[[[self xmppSharedManager] xmppStream] myJID] full]];
    NSXMLElement *query = [NSXMLElement elementWithName:@"query"];
    [query addAttributeWithName:@"xmlns" stringValue:@"http://jabber.org/protocol/disco#items"];
    [iq addChild:query];
    [[[self xmppSharedManager] xmppStream] sendElement:iq];

我面临的问题是,新创建的小组可以在不发送邀请的情况下查看我的所有名单。我需要向小组展示接受小组请求的情况。请建议我在哪里做错了

0 个答案:

没有答案