XMPPFramework - How to create a group chat room?

有些话、适合烂在心里 提交于 2019-12-19 04:05:00

问题


I have an application which I am using for one-to-one chat. Now I need to implement group chat. I know it is possible with XMPPFramework and there is a class called XMPPRoom which we can use to create a room or join a room. But I am unable to implement that in my project.

Can anyone please provide me some ideas, suggestions and if possible a sample application. Thanks in advance :)


回答1:


here you have a script that allows to connect to a room

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

In order to do this you should have access to the xmppStream.




回答2:


- (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");
        }
    }


来源:https://stackoverflow.com/questions/9032279/xmppframework-how-to-create-a-group-chat-room

易学教程内所有资源均来自网络或用户发布的内容,如有违反法律规定的内容欢迎反馈
该文章没有解决你所遇到的问题?点击提问,说说你的问题,让更多的人一起探讨吧!