I am trying to create multi user chat using XMPP(smack). After creation of room when i try to join to chat room then there is no entry of joined member in ofmucmember.
Creation of room code is as below :
public void createMultiUserChatRoom(String roomName, String nickName) {
MultiUserChatManager multiUserChatManager = MultiUserChatManager.getInstanceFor(connection);
MultiUserChat multiUserChat = multiUserChatManager.getMultiUserChat(roomName+"@conference.localhost");
try {
multiUserChat.create(nickName);
Form form = multiUserChat.getConfigurationForm();
Form submitForm = form.createAnswerForm();
List<FormField> formFieldList = submitForm.getFields();
for (FormField formField : formFieldList) {
if(!FormField.Type.hidden.equals(formField.getType()) && formField.getVariable() != null) {
submitForm.setDefaultAnswer(formField.getVariable());
}
}
submitForm.setAnswer("muc#roomconfig_persistentroom", true);
submitForm.setAnswer("muc#roomconfig_publicroom", true);
submitForm.setAnswer("muc#roomconfig_enablelogging", true);
submitForm.setAnswer("x-muc#roomconfig_reservednick", false);
submitForm.setAnswer("x-muc#roomconfig_canchangenick", false);
submitForm.setAnswer("x-muc#roomconfig_registration", false);
submitForm.setAnswer("muc#roomconfig_passwordprotectedroom", false);
submitForm.setAnswer("muc#roomconfig_roomname", roomName);
submitForm.setAnswer("muc#roomconfig_whois", Arrays.asList("none"));
multiUserChat.sendConfigurationForm(submitForm);
} catch (Exception e) {
e.printStackTrace();
}
}
Code for joining the created room is as below:
public void joinMultiUserChatRoom(String userName, String roomName) {
MultiUserChatManager manager = MultiUserChatManager.getInstanceFor(connection);
MultiUserChat multiUserChat = manager.getMultiUserChat(roomName + "@conference.localhost");
DiscussionHistory history = new DiscussionHistory();
history.setMaxStanzas(0);
try {
multiUserChat.join(userName);
multiUserChat.sendMessage(userName +" : You have joined the group : " + roomName);
Presence presence = multiUserChat.getOccupantPresence(roomName + "@conference.localhost/" + userName);
presence.setMode(Presence.Mode.available);
connection.sendStanza(presence);
} catch (Exception e) {
e.printStackTrace();
}
}
Response from server :
<message to="admin@localhost/Smack" id="h7axM-14" type="groupchat" from="[email protected]/roy"><body>roy : You have joined the group : team6</body><x xmlns="jabber:x:delay" stamp="20160623T12:15:50" from="[email protected]/roy"/></message>
presence :<presence to='admin@localhost/Smack' id='WR9Dy-12'><x xmlns='http://jabber.org/protocol/muc#user'><item affiliation='owner' jid='admin@localhost/Smack' role='moderator'></item></x><c xmlns='http://jabber.org/protocol/caps' hash='sha-1' node='http://www.igniterealtime.org/projects/smack' ver='NfJ3flI83zSdUDzCEICtbypursw='/></presence>
I am not getting any error. Can anybody tell me where i am wrong here?