Development environment:
Client: smack 4.1.1
Server: openfire 3.9.3
Code:
String roomId = “test003”;
String name=“test_group_chat”;
String desc = “the test group chat”;
String nick=“test”;
try {
MultiUserChatManager manager = MultiUserChatManager.getInstanceFor(XmppConnectionManager.getInstance().getConnection());
MultiUserChat muc = manager.getMultiUserChat(StringUtils.getGroupRootFullId(roomId));
muc.create(nick);
// User1 (which is the room owner) configures the room as a moderated room
Form form = muc.getConfigurationForm();
Form answerForm = form.createAnswerForm();
answerForm.setAnswer(“muc#roomconfig_roomname”, name);
answerForm.setAnswer(“muc#roomconfig_roomdesc”, desc);
answerForm.setAnswer(“muc#roomconfig_presencebroadcast”, “moderator”);
answerForm.setAnswer(“muc#roomconfig_whois”, “moderator”);
answerForm.setAnswer(“muc#roomconfig_publicroom”, “1”);
// answerForm.setAnswer(“muc#roomconfig_moderatedroom”, “1”);
answerForm.setAnswer(“muc#roomconfig_maxusers”, “500”);
answerForm.setAnswer(“muc#roomconfig_persistentroom”, “1”);
muc.sendConfigurationForm(answerForm);
muc.join(nick);
} catch (XMPPException e) {
e.printStackTrace();
}catch (SmackException.NoResponseException e) {
e.printStackTrace();
} catch (SmackException.NotConnectedException e) {
e.printStackTrace();
}catch (SmackException e) {
e.printStackTrace();
}
Chat rooms created successfully, but the name, description settings fail, chat room is not permanent