#pragma mark - 创建房间
-(void)createGroup:(NSString*)groupName{
@try {
NSString *username=@"111";//[self.userDefault valueForKey:@"userid"];
NSXMLElement *presenceElement=[NSXMLElement elementWithName:@"presence"];
[presenceElement addAttributeWithName:@"type" stringValue:@"groupchat"];
[presenceElement addAttributeWithName:@"from" stringValue:[NSString stringWithFormat:@"%@@%@",username,DOMAINSERVERNAME]];
[presenceElement addAttributeWithName:@"to" stringValue:[NSString stringWithFormat:@"%@@conference.%@/%@",groupName,DOMAINSERVERNAME,username]];
NSXMLElement *xElement=[NSXMLElement elementWithName:@"x" xmlns:@"http://jabber.org/protocol/muc"];
NSXMLElement *historyElement=[NSXMLElement elementWithName:@"history"];
[xElement addChild:historyElement];
[presenceElement addChild:xElement];
[[[self appDelegate] xmppStream] sendElement:presenceElement];
}
@catch (NSException *exception) {
XMPPRoomCoreDataStorage *rosterstorage =[[XMPPRoomCoreDataStorage alloc] init];
XMPPRoom *xmppRoom = [[XMPPRoom alloc] initWithRoomStorage:rosterstorage jid:[XMPPJID jidWithString:@"随机房间名字@conference.appledemacbook-pro.local"] dispatchQueue:dispatch_get_main_queue()];
[xmppRoom activate:[[self appDelegate]xmppStream]];
[xmppRoom joinRoomUsingNickname:@"Dev iphone" history:nil];
[[[self appDelegate] xmppStream] addDelegate:self delegateQueue:dispatch_get_main_queue()];
[xmppRoom addDelegate:self delegateQueue:dispatch_get_main_queue()];
}
}
之后在didreceiveIQ 会收到东西