2014-01-20 24 views
0

接受邀请在我的应用程序,如果我发送邀请其他用户,然后主持人和谁的请求将加入聊天室,但如果另一个用户发送请求所有然后所有用户先前房间的主持人是未收到邀请用户不在XMPPRoom

例如:
用户1将发送邀请房间1用户2用户3然后所有三个房间1
如果用户2将发送邀请函室2用户1用户3然后用户1个意志没有得到邀请。
并且如果用户3将发送邀请函室3然后用户仅3是在房间目前和所有另外两个没有得到邀请了。

在我的应用我想请其他用户的这一要求

XMPPRoomMemoryStorage * _roomMemory = [[XMPPRoomMemoryStorage alloc]init]; 
NSString* roomID = [NSString stringWithFormat:@"[email protected] id"]; 
XMPPJID * roomJID = [XMPPJID jidWithString:roomID]; 
xmppRoom = [[XMPPRoom alloc] initWithRoomStorage:_roomMemory jid:roomJID dispatchQueue:dispatch_get_main_queue()]; 
[xmppRoom addDelegate:_roomMemory delegateQueue:dispatch_get_main_queue()]; 
[xmppRoom activate:xmppStream]; 
[xmppRoom joinRoomUsingNickname:[NSString stringWithFormat:@"%@",strCureentUserName] history:nil]; 

//.........inviting the Friend....... 
for (int i=0; i<[arrUserName count];i++) { 
    [xmppRoom inviteUser:[XMPPJID jidWithString:[NSString stringWithFormat:@"Invite user's ID"]] withMessage:@"Come Join me in this room"]; 
} 

[xmppRoom fetchConfigurationForm]; 
[xmppRoom configureRoomUsingOptions:nil]; 

和其他用户获得邀请在这里

- (void)xmppStream:(XMPPStream *)sender didReceiveMessage:(XMPPMessage *)message 
{ 
NSXMLElement * x = [message elementForName:@"x" xmlns:XMPPMUCUserNamespace]; 
NSXMLElement * invite = [x elementForName:@"invite"]; 
NSXMLElement * decline = [x elementForName:@"decline"]; 
NSXMLElement * directInvite = [message elementForName:@"x" xmlns:@"jabber:x:conference"]; 
NSString *msg1 = [[message elementForName:@"body"]stringValue]; 
NSString *from1 = [[message attributeForName:@"from"]stringValue]; 
if (invite || directInvite) 
{ 
    NSLog(@"come in invite method of if condition"); 

    [self createAndEnterRoom:from1 Message:msg1]; 
    return; 
} 

如何从所有用户获得邀请所有的时间。
任何形式的帮助,欢迎...
在此先感谢。

回答

1

实际上,我的工作就可以了,我用XMPPMUC委托(MUC代表MultiUserChat)

委托有这个方法:

-(void)xmppMUC:(XMPPMUC *)sender roomJID:(XMPPJID *)roomJID didReceiveInvitation:(XMPPMessage *)message 
{ 
} 

我还没有这样做,但我想这你可以搜索一下这个...

+0

我没有这个人......从我上面的代码中,你只要把整个邀请码在for循环,所以从每次用户加入会议室并向阵列中的每个朋友发送邀请。可能这不是正确的,但我必须在更短的时间内完成,所以我用这个逻辑做了。如果你发现任何东西,请把它放在这里供其他人使用......并感谢时间兄弟...... – Sam

0

我认为你犯的错误,同时邀请users.You只是使用的用户数组来邀请其他国家的人民这很好,但邀请函必须发送时,这XMPPRooms的委托方法调用

- (void)xmppRoomDidJoin:(XMPPRoom *)sender 
{ 
    /** 
    * You can read from an array containing participants in a for-loop 
    * and send multiple invites in the same way here 
    */ 

    [sender inviteUser:[XMPPJID jidWithString:@"arpan"] withMessage:@"Greetings!"]; 
} 

只需使用XMPPRoomdelegates以适当的方式,邀请user.Refer变薄链接,代表.. XMPPFramework - How to create a MUC room and invite users?