我做這個使用下面的代碼。
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