我已经写了这个用于创建空间的代码。使用这个我在openfire中创造了空间。
-(void)createGroup:(NSString*)groupName
{
XMPPRoomCoreDataStorage *rosterstorage = [[XMPPRoomCoreDataStorage alloc] init];
xmppRoom = [[XMPPRoom alloc] initWithRoomStorage:rosterstorage jid:[XMPPJID jidWithString:[NSString stringWithFormat:@"%@@conference.%@/%@",groupName,@"server",self.strUsername]] dispatchQueue:dispatch_get_main_queue()];
[xmppRoom activate:[self xmppStream]];
[xmppRoom joinRoomUsingNickname:@"nickname" history:nil];
[xmppRoom addDelegate:self delegateQueue:dispatch_get_main_queue()];
[self performSelector:@selector(ConfigureNewRoom) withObject:nil afterDelay:5];
}
-(void)ConfigureNewRoom
{
[xmppRoom fetchConfigurationForm];
[xmppRoom configureRoomUsingOptions:nil];
}
现在我想在群组中添加好友/用户。那怎么能这样呢?提前谢谢。
答案 0 :(得分:1)
//使用它完成
XMPPRoomMemoryStorage *roomMemoryStorage = [[XMPPRoomMemoryStorage alloc] init];
NSString *strJid = [NSString stringWithFormat:@"%@@conference.%@/%@",groupname,strHostname,self.strUsername];
self.xmppRoom = [[XMPPRoom alloc] initWithRoomStorage:roomMemoryStorage jid:[XMPPJID jidWithString:strJid] dispatchQueue:dispatch_get_main_queue()];
[self.xmppRoom addDelegate:self delegateQueue:dispatch_get_main_queue()];
[self.xmppRoom activate:self.xmppStream];
[self.xmppRoom joinRoomUsingNickname:self.strUsername history:nil];
//inviting
NSString *strInvitedUserName = [NSString stringWithFormat:@"%@@%@",personName,strHostname];
[self.xmppRoom inviteUser:[XMPPJID jidWithString:strInvitedUserName] withMessage:message];
答案 1 :(得分:-1)
您可以通过以下方式将其添加到您的名单中:
[[[self appDelegate] xmppRoster] addUser:[XMPPJID jidWithString:@"userName"] withNickname:[NSString stringWithFormat:@"%@ %@", firstName, lastName] groups:[NSArray arrayWithObjects:@"general", nil]];
并检查:
XMPPRosterCoreDataStorage *xmppRosterStorage = [[self appDelegate] xmppRosterStorage];
BOOL knownUser = [xmppRosterStorage userExistsWithJID:[XMPPJID jidWithString:@"userName"] xmppStream:[self xmppStream]];