0

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

XMPPFramework - 实现群聊 (MUC)

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

任何人都可以建议这是实现这一点的确切方法,以及我如何获取成员列表。

4

2 回答 2

1

使用创建 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 的用户列表

于 2016-01-27T11:18:20.747 回答
0

这是服务器中默认启用的配置,因此无需设置,我们必须自定义服务器以使成员甚至离线并留出空间。从而达到显示其他聊天应用程序成员的要求。

于 2016-01-28T07:39:24.580 回答