2016-06-23 3 views
1

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> 

私はないですエラーが発生しました。誰が私がここで間違っているか教えていただけますか?

答えて

0

あなたが部屋に参加したという理由だけでメンバーを取得することはありません。部屋に入室した後は、の参加者がXEP-0045の用語で使用されています。

+0

その参加者はどのようにデータベースにエントリを持っていますか? – Jennifer

+0

私はOpenfireが参加者をデータベースに保存するとは思わない – Flow

+0

はい、データベースにメンバーを保存します。私はそれをOpenfireサーバーから追加することでチェックしました。 – Jennifer

1

コンフィギュレーションフォームを記入すると、次のセクションを記入する必要があります。

<field 
     label='Room Admins' 
     type='jid-multi' 
     var='muc#roomconfig_roomadmins'> 
    <value>[email protected]</value> 
    <value>[email protected]</value> 
    </field> 

<field 
      label='Room Owners' 
      type='jid-multi' 
      var='muc#roomconfig_roomowners'/> 

管理者と所有者がofMucAffiliation表にし、設定が更新され、既存の管理者または所有者は、その後、言及されていない場合、保存されていますサーバーは所属がメンバーに変更されたとみなし、エントリをofMucMemberテーブルに移動します。

関連する問題