ios – XMPPFramework – 从Openfire Server检索归档的消息

前端之家收集整理的这篇文章主要介绍了ios – XMPPFramework – 从Openfire Server检索归档的消息前端之家小编觉得挺不错的,现在分享给大家,也给大家做个参考。
我正在使用XMPP和openfire服务器开发iPhone的聊天应用程序,OpenFire服务器正在存储用户之间的所有聊天记录,但是当我尝试检索特定用户的聊天记录时,我只得到聊天消息的日期和数量实际的短信

我已经在openfire上安装了用于邮件归档的打开的归档插件

这是我传递给Openfire Server的节

<iq type='get' id='pk1'>
    <list xmlns='urn:xmpp:archive'
    with='piyush@openfire'>
    <set xmlns='http://jabber.org/protocol/rsm'>
    <max>30</max>
    </set>
    </list>
    </iq>

这是我从服务器收到的结果

<iq type="result" id="pk1" to="vivek@openfire/iphone">
  <list xmlns="urn:xmpp:archive">
  <chat with="piyush@openfire" start="2012-07-04T13:16:12.291Z"/>
  <chat with="piyush@openfire" start="2012-07-05T08:25:31.555Z"/>
  <chat with="piyush@openfire" start="2012-07-05T12:38:24.098Z"/>
  <set xmlns="http://jabber.org/protocol/rsm">
  <first index="0">15</first>
  <last>25</last>
  <count>3</count>
  </set>
  </list>
  </iq>

这是我想要的结果,我预期的结果

<iq type='result' to='vivek@openfire/iphone' id='page1'>
 <chat xmlns='urn:xmpp:archive'
    with='piyush@openfire'
    start='2012-07-04T13:16:12.291Z'
    subject='She speaks!'
    version='4'>
<from secs='0'><body>Art thou not Romeo,and a Montague?</body></from>
<to secs='11'><body>Neither,fair saint,if either thee dislike.</body></to>
.
[98 more messages]
.
<from secs='9'><body>How cam'st thou hither,tell me,and wherefore?</body></from>
<set xmlns='http://jabber.org/protocol/rsm'>
  <first index='0'>0</first>
  <last>99</last>
  <count>217</count>
</set>

请帮我取得理想的结果

谢谢

解决方法

您必须使用< retrieve>执行请求(见 http://xmpp.org/extensions/xep-0136.html),那么你可以从收到的< list>结果.例如:

发送:

<iq type='get' id='pk1'>
       <list xmlns='urn:xmpp:archive'
               with='piyush@openfire'>
        <set xmlns='http://jabber.org/protocol/rsm'>
            <max>30</max>
        </set>
      </list>
   </iq>

接收:

<iq type="result" id="pk1" to="vivek@openfire/iphone">
     <list xmlns="urn:xmpp:archive">
      <chat with="piyush@openfire" start="2012-07-04T13:16:12.291Z"/>
      <chat with="piyush@openfire" start="2012-07-05T08:25:31.555Z"/>
      <chat with="piyush@openfire" start="2012-07-05T12:38:24.098Z"/>
      <set xmlns="http://jabber.org/protocol/rsm">
          <first index="0">15</first>
           <last>25</last>
           <count>3</count>
      </set>
    </list>
 </iq>

现在您选择启动和发送之一(日期和时间必须是精确的):

<iq type='get' id='pk1'>
    <retrieve xmlns='urn:xmpp:archive'
        with='piyush@openfire''
        start='2012-07-04T13:16:12.291Z'>
     <set xmlns='http://jabber.org/protocol/rsm'>
       <max>100</max>
     </set>
    </retrieve>
 </iq>

你会收到这样的东西(取决于最大值 – > max = 30,bodies = 30):

<iq type='result' to='vivek@openfire/iphone' id='page1'>
      <chat xmlns='urn:xmpp:archive'
             with='piyush@openfire'
              start='2012-07-04T13:16:12.291Z'
            subject='She speaks!'
       version='4'>
         <from secs='0'><body>Art thou not Romeo,and a Montague?</body></from>
         <to secs='11'><body>Neither,if either thee dislike.</body></to>
          .
          [28 more messages]
          .
         <from secs='9'><body>How cam'st thou hither,and therefore?           </body>   
         </from>
      <set xmlns='http://jabber.org/protocol/rsm'>
       <first index='0'>0</first>
       <last>29</last>
       <count></count>
     </set>
  <iq>

猜你在找的iOS相关文章