Ios 将用户添加到xmpp文件室
您好,我知道有很多关于这个问题,但我仍然不能找出什么是问题。我已使用以下代码成功创建了组Ios 将用户添加到xmpp文件室,ios,xmpp,Ios,Xmpp,您好,我知道有很多关于这个问题,但我仍然不能找出什么是问题。我已使用以下代码成功创建了组 - (void)createGroup { iXmppEngine.userID = @"lahore123@hassan.local"; iXmppEngine.userPass = @"password123"; self.rosterstorage =[[XMPPRoomCoreDataStorage alloc] init]; XMPPRoom *xmppRoom =
- (void)createGroup
{
iXmppEngine.userID = @"lahore123@hassan.local";
iXmppEngine.userPass = @"password123";
self.rosterstorage =[[XMPPRoomCoreDataStorage alloc] init];
XMPPRoom *xmppRoom = [[XMPPRoom alloc] initWithRoomStorage:self.rosterstorage jid:[XMPPJID jidWithString:@"test@conference.hassan.local"] dispatchQueue:dispatch_get_main_queue()];
[xmppRoom activate:[[self iXmppEngine]xmppStream]];
[xmppRoom joinRoomUsingNickname:@"Dev iphone" history:nil];
[[[self iXmppEngine] xmppStream] addDelegate:self delegateQueue:dispatch_get_main_queue()];
[xmppRoom addDelegate:self delegateQueue:dispatch_get_main_queue()];
[self performSelector:@selector(joinRoom) withObject:nil afterDelay:4];
}
为了添加用户,我使用了以下代码。我调用了这个函数,延迟了5秒,这样在添加用户之前就可以成功地创建房间了
- (void)joinRoom
{
self.iXmppEngine.userID = @"lahore@hassan.local";
// self.rosterstorage = [[XMPPRoomCoreDataStorage alloc] init];
XMPPRoom *xmppRoom = [[XMPPRoom alloc] initWithRoomStorage:self.rosterstorage jid:[XMPPJID jidWithString:@"test@conference.hassan.local"] dispatchQueue:dispatch_get_main_queue()];
[xmppRoom activate:[[self iXmppEngine] xmppStream]];
[xmppRoom joinRoomUsingNickname:@"lahore" history:nil];
[xmppRoom fetchConfigurationForm];
[xmppRoom configureRoomUsingOptions:nil];
[xmppRoom addDelegate:[self iXmppEngine] delegateQueue:dispatch_get_main_queue()];
}
我做错了什么找不到。创建和加入(已创建房间或接受加入房间的邀请)房间是两种不同的场景
//会议室服务器是MUC的域名
要创建组,请执行以下操作:
- (void)createChatRoom:(NSString *) newRoomName
{
XMPPJID *roomJID = [XMPPJID jidWithString:[NSString stringWithFormat:@"%@@%@", newRoomName, CONFERENCE_ROOM_SERVER]];
XMPPRoomMemoryStorage *roomMemoryStorage = [[XMPPRoomMemoryStorage alloc] init];
xmppRoom = [[XMPPRoom alloc]
initWithRoomStorage:roomMemoryStorage
jid:roomJID
dispatchQueue:dispatch_get_main_queue()];
[xmppRoom activate:[self xmppStream]];
[xmppRoom addDelegate:self delegateQueue:dispatch_get_main_queue()];
[xmppRoom joinRoomUsingNickname:@"Your Nick Name" history:nil];
}
[sender inviteUser:[XMPPJID jidWithString:inviteUserJID] withMessage:@"Any Message"];
在此委托中成功创建组后,您将得到响应:
- (void)xmppRoomDidCreate:(XMPPRoom *)sender
现在通过以下方式邀请用户:
- (void)createChatRoom:(NSString *) newRoomName
{
XMPPJID *roomJID = [XMPPJID jidWithString:[NSString stringWithFormat:@"%@@%@", newRoomName, CONFERENCE_ROOM_SERVER]];
XMPPRoomMemoryStorage *roomMemoryStorage = [[XMPPRoomMemoryStorage alloc] init];
xmppRoom = [[XMPPRoom alloc]
initWithRoomStorage:roomMemoryStorage
jid:roomJID
dispatchQueue:dispatch_get_main_queue()];
[xmppRoom activate:[self xmppStream]];
[xmppRoom addDelegate:self delegateQueue:dispatch_get_main_queue()];
[xmppRoom joinRoomUsingNickname:@"Your Nick Name" history:nil];
}
[sender inviteUser:[XMPPJID jidWithString:inviteUserJID] withMessage:@"Any Message"];