Smack 4.2:将管理员添加到MUC房间

时间:2017-09-06 10:12:56

标签: java android xmpp ejabberd smack

我有问题将管理员,版主等设置到我要创建的MUC房间。

以下是代码:

            // Create the nickname.
        Resourcepart nickname = Resourcepart.from("test");

        // Create the room
        chatRoom.create(nickname);

        // Set MUC config
        Form form = chatRoom.getConfigurationForm().createAnswerForm();
        form.setAnswer("muc#roomconfig_publicroom", true);
        form.setAnswer("muc#roomconfig_roomname", mGroupName);
        form.setAnswer("muc#roomconfig_persistentroom", true);
        form.setAnswer("muc#roomconfig_moderatedroom", true);

        FormField roomAdmins = new FormField();
        roomAdmins.setLabel("muc#roomconfig_roomadmins");
        roomAdmins.addValue("test@localhost");
        form.addField(roomAdmins);

        FormField accessMembers = new FormField();
        accessMembers.setLabel("muc#roomconfig_getmemberlist");
        accessMembers.addValue("participant");
        form.addField(accessMembers);


        chatRoom.sendConfigurationForm(form);

创建房间时没有任何错误。

如果我想用“multiUserChat.getAdmins()。size();”来获取管理员,我总是0。

房间所有者总是被设置。多数民众赞成工作但我无法授予管理员访问现有所有者或其他加入会议室的用户的权限。

这是日志:

09-06 12:05:05.055 2531-3165/********* D/SMACK: SENT (0): <iq to='hdzy4zzdp31504692259578@conference.localhost' id='e8Ook-30' type='set'><query xmlns='http://jabber.org/protocol/muc#admin'><item affiliation='admin' jid='hdzy4zzdp3qcvv55u@localhost'></item></query></iq><r xmlns='urn:xmpp:sm:3'/>

09-06 12:05:05.145 2531-3166/********** D/SMACK: RECV (0): <iq from='hdzy4zzdp31504692259578@conference.localhost' to='HdzY4Zzdp3QCVv55U@localhost/test' id='e8Ook-30' type='error'><query xmlns='http://jabber.org/protocol/muc#admin'><item affiliation='admin' jid='hdzy4zzdp3qcvv55u@localhost'/></query><error code='405' type='cancel'><not-allowed xmlns='urn:ietf:params:xml:ns:xmpp-stanzas'/><text xmlns='urn:ietf:params:xml:ns:xmpp-stanzas'>Changing role/affiliation is not allowed</text></error></iq>

XMPP软件是ejabberd(16.09)服务器。

提前致谢。

0 个答案:

没有答案