XMPPFramework IOS - 实施 MUC

XMPPFramework IOS - Implementing MUC

参考这个我在实现群聊配置

XMPPFramework - Implement Group Chat (MUC)

然而,作为参与者而不是主持人,我无法获得成员列表。我已经尝试阅读多个要求实现 'muc#roomconfig_getmemberlist' 的堆栈答案,但是 XMPPRoom 的 fetchconfiguration 委托没有在回调中给出此字段值。

任何人都可以告诉我实现这个的确切方法以及我如何获取成员列表。

使用

创建 xmpp 房间
/**
 This fuction is used to setup room with roomId
 */
-(void)setUpRoom:(NSString *)ChatRoomJID
{
    if (!ChatRoomJID)
    {
        return;
    }
    // Configure xmppRoom
    XMPPRoomMemoryStorage *roomMemoryStorage = [[XMPPRoomMemoryStorage alloc] init];

    XMPPJID *roomJID = [XMPPJID jidWithString:ChatRoomJID];

    xmppRoom = [[XMPPRoom alloc] initWithRoomStorage:roomMemoryStorage jid:roomJID dispatchQueue:dispatch_get_main_queue()];

    [xmppRoom activate:xmppStream];
    [xmppRoom addDelegate:self delegateQueue:dispatch_get_main_queue()];

    NSXMLElement *history = [NSXMLElement elementWithName:@"history"];
    [history addAttributeWithName:@" maxchars" stringValue:@"0"];
    [xmppRoom joinRoomUsingNickname:xmppStream.myJID.user
                            history:history
                           password:nil];


    [self performSelector:@selector(ConfigureNewRoom:) withObject:nil afterDelay:4];

}

/**
 This fuction is used configure new
 */
- (void)ConfigureNewRoom:(id)sender
{
    [xmppRoom configureRoomUsingOptions:nil];
    [xmppRoom fetchConfigurationForm];
    [xmppRoom fetchBanList];
    [xmppRoom fetchMembersList];
    [xmppRoom fetchModeratorsList];

}

创建房间后使用Xmpp房间的Delegate方法

- (void)xmppRoom:(XMPPRoom *)sender occupantDidJoin:(XMPPJID *)occupantJID withPresence:(XMPPPresence *)presence


- (void)xmppRoom:(XMPPRoom *)sender occupantDidLeave:(XMPPJID *)occupantJID withPresence:(XMPPPresence *)presence

使用这两种委托方法,您可以轻松维护加入 MUC Room 的用户列表

这是在服务器中默认启用的配置,因此无需设置,我们必须自定义服务器才能使成员离线并留出空间。从而实现像其他聊天应用成员一样显示的要求。