XMPP(スティック)を使用してマルチユーザーチャットを作成しようとしています。チャットルームに参加しようとするとルームが作成された後、ofmucmemberに参加メンバーのエントリはありません。部屋コードのXMPP(SMACK)でMUCにメンバーを追加する
作成は以下の通りです:作成したルームに参加するための
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();
}
}
コードは以下の通りです:サーバーから
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();
}
}
応答:
<message to="[email protected]/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='[email protected]/Smack' id='WR9Dy-12'><x xmlns='http://jabber.org/protocol/muc#user'><item affiliation='owner' jid='[email protected]/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>
私はないですエラーが発生しました。誰が私がここで間違っているか教えていただけますか?
その参加者はどのようにデータベースにエントリを持っていますか? – Jennifer
私はOpenfireが参加者をデータベースに保存するとは思わない – Flow
はい、データベースにメンバーを保存します。私はそれをOpenfireサーバーから追加することでチェックしました。 – Jennifer