2017-02-07 62 views
10

讓這兩個用戶的歷史我拿來的歷史從Openfire的由明火安裝明火插件,並試圖此代碼。在拿聊天記錄我不是從Openfire的

let iq1 = DDXMLElement(name: "iq") 
    iq1.addAttribute(withName: "type", stringValue: "get") 
    iq1.addAttribute(withName: "id", stringValue: "0") 
    let retrieve = DDXMLElement(name: "retrieve", xmlns: "urn:xmpp:archive") 
    retrieve?.addAttribute(withName: "with", stringValue: "[email protected]") 
    let set = DDXMLElement(name: "set", xmlns: "http://jabber.org/protocol/rsm") 
    let max = DDXMLElement(name: "max", stringValue: "50") 
    iq1.addChild(retrieve!) 
    retrieve?.addChild(set!) 
    set?.addChild(max) 
    stream?.send(iq1) 

現在我沒有從雙方獲得歷史。這是我得到的結果。

<iq xmlns="jabber:client" 
 
type="result" 
 
id="0" 
 
to="[email protected]/5qsinh1syg"> 
 

 
<chat xmlns="urn:xmpp:archive" 
 
with="[email protected]" 
 
start="2017-02-07T06:28:33.691Z"> 
 

 
\t <from secs="0"> 
 
\t <body>hello</body> 
 
\t </from> 
 

 
\t <from secs="405"> 
 
\t <body>hiii</body> 
 
\t </from> 
 

 
\t <from secs="580"> 
 
\t <body>Hey</body> 
 
\t </from> 
 

 
\t <from secs="599"> 
 
\t <body>HooooE</body> 
 
\t </from> 
 

 
\t <from secs="628"> 
 
\t <body>hOo</body> 
 
\t </from> 
 

 
\t <from secs="907"> 
 
\t <body>Raman here</body> 
 
\t </from> 
 
\t 
 
\t <from secs="931"> 
 
\t <body>Raman here ONE</body> 
 
\t </from> 
 

 
\t <from secs="1273"> 
 
\t <body>Raman here</body> 
 
\t </from> 
 

 
\t <from secs="1558"> 
 
\t <body> Raman from SPark </body> 
 
\t </from> 
 

 
\t <from secs="1571"> 
 
\t <body> Raman from SPark One</body> 
 
\t </from> 
 

 
\t <from secs="1782"> 
 
\t <body>Raman from SPark </body> 
 
\t </from> 
 

 
\t <from secs="2651"> 
 
\t <body>Raman FiVE</body> 
 
\t </from> 
 

 
\t <from secs="2810"> 
 
\t <body>Raman Three</body> 
 
\t </from> 
 

 
\t <from secs="2810"> 
 
\t <body>Raman FOur</body> 
 
\t </from> 
 

 
\t <from secs="3534"> 
 
\t <body>RAMAN SIX</body> 
 
\t </from> 
 

 
\t <from secs="4105"> 
 
\t <body>Raman OKK</body> 
 
\t </from> 
 

 
\t <from secs="4113"> 
 
\t <body>OKKK l</body> 
 
\t </from> 
 

 
\t <from secs="4130"> 
 
\t <body>UST</body> 
 
\t </from> 
 

 
\t <set xmlns="http://jabber.org/protocol/rsm"> 
 
\t \t <first index="0">0</first> 
 
\t \t <last>17</last> 
 
\t \t <count>18</count> 
 
\t </set> 
 
</chat> 
 
</iq>

這是拉曼所有信息不BENTICk因爲這兩個用戶參與聊天的同時獲得歷史我只得到拉曼消息。不是BENTICk 如何從雙方用戶獲取歷史記錄。

請幫忙。

+0

您使用LDAP或內置的Openfire數據庫? – OlaB

+0

它是默認的openfire數據庫。 –

+0

是否允許從服務器>服務器設置 - >消息審覈策略啓用消息審覈? – OlaB

回答

-1

我已經實現了同一發送給定的智商 得到的消息,並從與我收到正確的結果。

let iQ = DDXMLElement.element(withName: "iq") as! DDXMLElement 
     iQ.addAttribute(withName: "type", stringValue: "get") 
       iQ.addAttribute(withName: "id", stringValue: (xmppHandler.xmppStream?.generateUUID())!) 
     let retrieve = DDXMLElement(name: "retrieve", xmlns: "urn:xmpp:archive") 
     retrieve?.addAttribute(withName: "with", stringValue: "\(JID!)@\(Utility.hostname)") 

     let set = DDXMLElement.element(withName: "set") as! DDXMLElement 
     set.addAttribute(withName: "xmlns", stringValue: "http://jabber.org/protocol/rsm") 
     let max = DDXMLElement.element(withName: "max") as! DDXMLElement 
     max.stringValue = "10" 
     max.addAttribute(withName:"xmlns", stringValue: "http://jabber.org/protocol/rsm") 

     iQ.addChild(retrieve!) 
     retrieve?.addChild(set) 
     set.addChild(max as DDXMLNode) 
     xmppHandler.xmppStream?.send(iQ) 

<iq type="get" id="7705EEC5-3385-42D4-B748-B39C204ADB90"><retrieve xmlns="urn:xmpp:archive" with="[email protected]"><set xmlns="http://jabber.org/protocol/rsm"><max xmlns="http://jabber.org/protocol/rsm">10</max></set></retrieve></iq> 

響應

<iq xmlns="jabber:client" type="result" id="7705EEC5-3385-42D4-B748-B39C204ADB90" to="[email protected]/Smack"> 
    <chat xmlns="urn:xmpp:archive" with="[email protected]" start="2017-02-28T09:55:27.068Z"> 
    <from secs="0" jid="[email protected]"> 
     <body>Hiii rajeev</body> 
    </from> 
    <to secs="52"> 
     <body>Hi 
     How r u</body> 
    </to> 
    <from secs="15" jid="[email protected]"><body>I am good</body></from> 
    <to secs="8"><body>What abt u</body></to> 
    <to secs="169"><body>Hello testing chat</body></to> 
    <from secs="10" jid="[email protected]"><body>Good</body></from> 
    <from secs="5" jid="[email protected]"><body>Continue </body></from> 
    <to secs="834"><body>Ok 
    </body></to> 
    <to secs="8"><body>Nice chat 
    </body></to> 
    <from secs="232" jid="[email protected]"><body>Heelo</body></from> 
    <set xmlns="http://jabber.org/protocol/rsm"><first index="0">0</first>  <last>9</last><count>574</count></set></chat></iq>