Hi Team,
I am unable to create a persistent room with below code snippet.
String groupServiceName = “goupName@conference.domainName”;
try{
// Get the MultiUserChatManager
MultiUserChatManager manager = MultiUserChatManager.getInstanceFor(connection);
// Create a MultiUserChat using an XMPPConnection for a room
MultiUserChat multiUserChat = manager.getMultiUserChat(JidCreate.entityBareFrom(groupServiceName));
// Create the room
multiUserChat.create(Resourcepart.from(“John”));
// Get the the room’s configuration form
Form form = multiUserChat.getConfigurationForm();
// Create a new form to submit based on the original form
Form submitForm = form.createAnswerForm();
// Add default answers to the form to submit
for (Iterator fields = form.getFields().iterator(); fields.hasNext() {
FormField field = (FormField) fields.next();
if (!FormField.Type.hidden.equals(field.getType()) && field.getVariable() != null) {
// Sets the default value as the answer
submitForm.setDefaultAnswer(field.getVariable());
}
}
submitForm.setAnswer(“muc#roomconfig_roomname”, “GroupB”);
submitForm.setAnswer(“muc#roomconfig_roomdesc”, “This is a Test Group”);
submitForm.setAnswer(“muc#roomconfig_publicroom”, true);
submitForm.setAnswer(“muc#roomconfig_persistentroom”, true);
submitForm.setAnswer(“x-muc#roomconfig_canchangenick”, true);
submitForm.setAnswer(“x-muc#roomconfig_registration”, true);
Hi Paul,
Thanks for the quick reply. Please find the attached documents for stanza reference along with the screenshot of Open Fire MUC room summary which indicates that the created room is not of persistent type. Also, there was no exception in the log.
I’m not an expert in MUC related stuff, but the fact, that Openfire responded with an to the configure form suggests, that the room is in fact persistent. You could try to query the room config in Smack after configuring the room to see, if it is persistent.
@Paul_Schaub
I checked the configuration details of the room and I get the following info:
Room Name: GroupB
Room Desc: This is a Test Group
Is Room Persistent: false
We can see that except persistent attribute all other attributes are in place and please find the attached document which distinguishes the room created from Smack API(GroupB) and another one is created from Open Fire Admin Console(groupx).
multiUserChatManager = MultiUserChatManager.getInstanceFor(connection);
multiUserChat = multiUserChatManager.getMultiUserChat(JidCreate.entityBareFrom(roomJID));
multiUserChat.create(Resourcepart.from(nickname));
Form form = multiUserChat.getConfigurationForm();
Form submitForm = form.createAnswerForm(); submitForm.getField("muc#roomconfig_publicroom").addValue("1");
submitForm.getField("muc#roomconfig_enablelogging").addValue("1");
submitForm.getField("x-muc#roomconfig_reservednick").addValue("0");
submitForm.getField("x-muc#roomconfig_canchangenick").addValue("0");
submitForm.getField("x-muc#roomconfig_registration").addValue("0");
submitForm.getField("muc#roomconfig_passwordprotectedroom").addValue("0");
submitForm.getField("muc#roomconfig_roomname").addValue(roomName);
submitForm.getField("muc#roomconfig_whois").addValue("participants");
submitForm.getField("muc#roomconfig_membersonly").addValue("1");
submitForm.getField("muc#roomconfig_persistentroom").addValue("1");
multiUserChat.sendConfigurationForm(submitForm);
I tried above thing and it works for me