【问题标题】:XMPPFramework - How to create a group chat room?XMPPFramework - 如何创建群聊室?
【发布时间】:2012-02-20 09:10:31
【问题描述】:

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

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

【问题讨论】:

  • 为什么你不能在你的项目中实现它?你试过什么?你遇到什么具体问题。请不要将 StackOverflow 用作要求人们为您完成工作的地方。

标签: ios xmpp xmppframework


【解决方案1】:
- (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");
        }
    }

【讨论】:

  • 嗨 suhail,你能解释一下什么是 MAX_ROOM_HISTORY 吗? -------- 它会显示错误,例如“使用未声明的标识符 MAX_ROOM_HISTORY”
  • 嗨,这是我自己的#定义值,你可以给任何整数值 thre
【解决方案2】:

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

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

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

【讨论】:

  • 这是新方法:[xmppRoom joinRoomUsingNickname:@"keithoys" history:nil];
猜你喜欢
  • 2014-06-16
  • 2013-03-05
  • 1970-01-01
  • 2013-09-24
  • 2013-10-16
  • 2014-01-19
  • 1970-01-01
  • 2012-07-10
  • 2014-05-22
相关资源
最近更新 更多