获取MucConfigurationNotSupportedException在android smack 4.2.0-beta1

时间:2016-08-01 08:13:17

标签: android xmpp ejabberd smack groupchat

我正在开发一对一聊天和群聊的聊天应用程序。

我已成功完成一对一聊天。

使用以下链接,我创建了群组聊天。

Link to create Group chat in smack 4.2.0-beta1

我可以在管理面板中看到该组,但只有一个用户可用,但我创建了这个有三个成员的组。 我在这里添加了我的代码。

 public void createGroupChat() {

        String DomainName = "conference."+ServiceAddress;
        // Create a MultiUserChat using a Connection for a room
// Get the MultiUserChatManager
        MultiUserChatManager manager = MultiUserChatManager.getInstanceFor(connection);
        try {
            EntityBareJid jid = JidCreate.entityBareFrom("mychatroom3" + "@"
                    + DomainName);

// Create a MultiUserChat using an XMPPConnection for a room
            MultiUserChat muc = manager.getMultiUserChat(jid);

// Prepare a list of owners of the new room
            Set<Jid> owners = JidUtil.jidSetFrom(new String[]{"admin" + "@"
                    + DomainName, "dev1" + "@"
                    + DomainName, "dev2" + "@"
                    + DomainName});

// Create the room
            Resourcepart nickname = Resourcepart.from("admin");
            muc.create(nickname).getConfigFormManager().setRoomOwners(owners).submitConfigurationForm();
            muc.join(nickname);
            Log.e("Group chat", "Created");
            Toast.makeText(context,
                    "Group chat" + "Created",
                    Toast.LENGTH_SHORT).show();
        } catch (XmppStringprepException e) {
            e.printStackTrace();
        } catch (MultiUserChatException.MucAlreadyJoinedException e) {
            e.printStackTrace();
        } catch (InterruptedException e) {
            e.printStackTrace();
        } catch (XMPPException.XMPPErrorException e) {
            e.printStackTrace();
        } catch (MultiUserChatException.MissingMucCreationAcknowledgeException e) {
            e.printStackTrace();
        } catch (NotConnectedException e) {
            e.printStackTrace();
        } catch (SmackException.NoResponseException e) {
            e.printStackTrace();
        } catch (MultiUserChatException.NotAMucServiceException e) {
            e.printStackTrace();
        } catch (MultiUserChatException.MucConfigurationNotSupportedException e) {
            e.printStackTrace();
        }
    }

我得到的例外

08-01 05:58:14.589 917-917/com.agarangroup.hello W/System.err: org.jivesoftware.smackx.muc.MultiUserChatException$MucConfigurationNotSupportedException: The MUC configuration 'muc#roomconfig_roomowners' is not supported by the MUC service
08-01 05:58:14.590 917-917/com.agarangroup.hello W/System.err:     at org.jivesoftware.smackx.muc.MucConfigFormManager.setRoomOwners(MucConfigFormManager.java:137)
08-01 05:58:14.590 917-917/com.agarangroup.hello W/System.err:     at com.agarangroup.hello.Services.MyXMPP.createGroupChat(MyXMPP.java:331)
08-01 05:58:14.590 917-917/com.agarangroup.hello W/System.err:     at com.agarangroup.hello.slidingtab.chats.GroupChatActivity.onCreate(GroupChatActivity.java:99)

1 个答案:

答案 0 :(得分:2)

有两种情况: 1)您的会议服务不支持所有者(在您的情况下依赖服务器,Ejabber,这听起来不正常)

2)您的配置表单未按照documentation说明完成,您需要创建完整的表单。

如何修复:替换此行:

 muc.create(nickname).getConfigFormManager().setRoomOwners(owners).submitConfigurationForm();

使用:

muc.create(nickname);
Form form = muc.getConfigurationForm().createAnswerForm();
form.setAnswer("muc#roomconfig_roomowners", owners);
muc.sendConfigurationForm(form); 

注意姓名:

您的 DomainName 它是服务会议名称+服务器域名。 所有者可以是JID( foo @ myserver )并且与服务无关(因此 foo@service.myserver 它不是有效用户,即使服务器会接受它)

修复您的所有者:

"admin" + "@" + ServiceAddress, "dev1" + "@" + ServiceAddress, "dev2" + "@" + ServiceAddress