3

我有一个用于一对一聊天的应用程序。现在我需要实现群聊。我知道 XMPPFramework 是可能的,并且有一个名为 XMPPRoom 的类,我们可以使用它来创建房间或加入房间。但我无法在我的项目中实现这一点。

谁能给我一些想法,建议,如果可能的话,提供一个示例应用程序。提前致谢 :)

4

2 回答 2

2

在这里,您有一个允许连接到房间的脚本

[xmppRoom activate:[self xmppStream]]; 
[xmppRoom createOrJoinRoom];

为此,您应该有权访问 xmppStream。

于 2012-01-27T13:14:49.133 回答
0
- (void)createOrJoinRoomWithRoomName:(NSString *)roomName nickName:(NSString *)nickName 
    {
        if(roomName && nickName)
        {
            _xmppRoomStorage = [XMPPRoomHybridStorage sharedInstance];
            XMPPJID *roomJid = [XMPPJID jidWithString:[NSString stringWithFormat:@"%@@%@.%@",roomName,@"conference",self.hostName]];
            _xmppRoom = [[XMPPRoom alloc] initWithRoomStorage:_xmppRoomStorage jid:roomJid];
            [_xmppRoom addDelegate:self delegateQueue:dispatch_get_main_queue()];
            [_xmppRoom activate:_xmppStream];
            NSXMLElement *history = [NSXMLElement elementWithName:@"history"];
            [history addAttributeWithName:@"maxstanzas" stringValue:MAX_ROOM_HISTORY];
            [_xmppRoom joinRoomUsingNickname:nickName history:history];
        }
        else
        {
            NSLog(@"room creation arguments missing");
        }
    }
于 2014-07-04T10:21:12.613 回答