powered by Jive Software

Unable to create persistent room with Smack 4.2.4


#1

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():wink: {
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);

        multiUserChat.sendConfigurationForm(submitForm);
    }
    catch (XmppStringprepException xse){
          xse.printStackTrace();
    }
    catch (SmackException.NoResponseException nre){
        nre.printStackTrace();
    }
    catch (XMPPException.XMPPErrorException xee){
        xee.printStackTrace();
    }
    catch (MultiUserChatException.MucAlreadyJoinedException mucaje){
        mucaje.printStackTrace();
    }
    catch (SmackException.NotConnectedException nce){
        nce.printStackTrace();
    }
    catch (MultiUserChatException.MissingMucCreationAcknowledgeException mmcae){
        mmcae.printStackTrace();
    }
    catch (MultiUserChatException.NotAMucServiceException namse){
        namse.printStackTrace();
    }
    catch(InterruptedException ie){
        ie.printStackTrace();
    }

And I am verifying persistent of the aforementioned room from Open Fire Admin Console, any suggestion will be helpful.
Thanks


#2

Can you give some more information, like what exactly doesn’t work, any exceptions that are thrown, or stanza logs?


#3

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.

stanza_logs.txt (8.5 KB)


#4

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.


#5

Where in the screenshot exactly is this indicated?


#6

@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).


#7

Hi rohit.pandey, i’m facing the same problem.

Did you fix it?

Thanks.


#8

Hi @rohit.pandey i found a workaround.

I tried:
answerForm.getField(“muc#roomconfig_persistentroom”).addValue(“1”);|

instead of

answerForm.setAnswer(“muc#roomconfig_persistentroom”, true);

and it works fine. It’s a thing to Smack developers work.