本文介绍了XMPPFramework - 从Openfire Server检索存档的消息的处理方法,对大家解决问题具有一定的参考价值,需要的朋友们下面随着小编来一起学习吧!

问题描述

我正在使用XMPP和openfire服务器为iPhone开发聊天应用程序,OpenFire服务器存储用户之间的所有聊天记录但是当我尝试检索特定用户的聊天记录时,我只得到聊天的日期和数量消息但不是实际的短信

I am developing a chat app for iPhone using XMPP and openfire server,OpenFire server is storing all the chat history between users but When I try to retrieve the chat history for a particular user I get only the date and the number of chat messages but not the actual text messages

我已经在openfire上安装了用于消息存档的开放存档插件

I have already installed open archive plugin for message archiving on 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>


请帮助我得到了想要的结果

Please Help me out to get the desired result

谢谢

推荐答案

你有使用< retrieve> 进行请求(请参阅)然后您可以从收到的< list> 结果中获取特定时间。例如:

You have to do a request with <retrieve> (see http://xmpp.org/extensions/xep-0136.html) then you can take a specific time from the received <list> result. For example:

发送:

    <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>            

现在你选择中的一个开始和发送(日期和小时必须是精确的):

Now you choose one of starts and send (date and hour must be exacts):

  <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,body = 30) :

You will receive something like this (depends the max value -> 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, fair saint, if either thee dislike.</body></to>
          .
          [28 more messages]
          .
         <from secs='9'><body>How cam'st thou hither, tell me, and therefore?           </body>   
         </from>
      <set xmlns='http://jabber.org/protocol/rsm'>
       <first index='0'>0</first>
       <last>29</last>
       <count></count>
     </set>
  <iq>

这篇关于XMPPFramework - 从Openfire Server检索存档的消息的文章就介绍到这了,希望我们推荐的答案对大家有所帮助,也希望大家多多支持!

09-24 22:16