我做这个使用下面的代码。
XMPPRoomCoreDataStorage * rosterstorage = [[XMPPRoomCoreDataStorage alloc] init];XMPPRoom * xmppRoom = [[XMPPRoom alloc] initWithRoomStorage:rosterstorage jid:[XMPPJID jidWithString:@“[email protected]”] dispatchQueue:dispatch_get_main_queue()];
[xmppRoom activate:[[self appDelegate]xmppStream]];
[xmppRoom joinRoomUsingNickname:@"DeveloperQ" history:nil];
[[[self appDelegate] xmppStream] addDelegate:self delegateQueue:dispatch_get_main_queue()];
[xmppRoom addDelegate:self delegateQueue:dispatch_get_main_queue()];
然后
- (无效)xmppRoomDidJoin:(XMPPRoom *)发件人
{
NSXMLElement * IQ = [NSXMLElement elementWithName:@ “IQ”];
[iq addAttributeWithName:@"id" stringValue:[NSString stringWithFormat:@"inroom-cr%@",groupName]];
[iq addAttributeWithName:@"to" stringValue::@"[email protected]"];
[iq addAttributeWithName:@"type" stringValue:@"set"];
NSXMLElement *query = [NSXMLElement elementWithName:@"query" xmlns:XMPPMUCOwnerNamespaceName];
NSXMLElement *xelem = [NSXMLElement elementWithName:@"x" xmlns:@"jabber:x:data"];
[xelem addAttributeWithName:@"type" stringValue:@"submit"];
[query addChild:xelem];
[iq addChild:query];
[[[self appDelegate] xmppStream] sendElement:iq];
}
海乔在这种情况下,我不能将用户添加到特定的组,首先我要创建新组则只有其可能的,其中扩展将提供此 – 2012-01-30 06:45:33
有没有这样的事,作为一个基于XMPP的空组。您可以分别存储空组的列表,也许使用PEP(XEP-0163:http://xmpp.org/extensions/xep-0163.html),或者如果没有该私有存储(XEP-0049:http:// xmpp.org/extensions/xep-0049.html)。对于其中任何一个,请使用您控制的新名称空间,但不要期望其他客户端能够看到空组。如果您对此感到强烈,请编写一个新的XEP,并将其提交给XSF:http://xmpp.org/xmpp-protocols/xmpp-extensions/submitting-a-xep/ – 2012-01-31 05:56:20