MUC configuration error : Couldn't find a field for the specified variable

 ̄綄美尐妖づ 提交于 2019-12-24 19:45:12

问题


I want to create group chat like whatsapp. i am using MUC service with ejabberd server. I have created group successfully but i unable to add member permanentantly in a group. I have also tried using send invitation and join group but it not work when user is offline. it is autometically remove user from group when it is offline.

So i have tried belove code to add member in a group but it gives error :

Couldn't find a field for the specified variable.

Here is my code :

EntityBareJid mucJid = JidCreate.entityBareFrom("groupname@conference.servicename");

MultiUserChatManager manager = MultiUserChatManager.getInstanceFor(conn);

MultiUserChat muc = manager.getMultiUserChat(mucJid);

Resourcepart nickname = Resourcepart.from("admin");

List<String> owners = new ArrayList<>();
owners.add("user1@servicename");
owners.add("user2@servicename");

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

Can anyone help me ?


回答1:


Hey @D G there is no way add member permanently in a group, XMPP kicks the room user while connection lost.

Here is a way which I'm using for this problem

while you create a group save your group detail and group members anywhere on your Server using API OR get room information from XMPP but I'd recommend save Groups detail using API because from XMPP not getting whole Room details which we need.

Then after while you create a connection while app open send group invitation to all groups members, so if any group member is online or connected he will join the group (make sure this process is in the background).

fro more info check XEP-0045: Multi-User Chat



来源:https://stackoverflow.com/questions/52512289/muc-configuration-error-couldnt-find-a-field-for-the-specified-variable

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