在获取聊天记录时,我没有从Openfire获得两个用户历史记录 [英] While fetching Chat History I am Not getting Both user History from Openfire

查看:308
本文介绍了在获取聊天记录时,我没有从Openfire获得两个用户历史记录的处理方法,对大家解决问题具有一定的参考价值,需要的朋友们下面随着小编来一起学习吧!

问题描述

我在openfire中通过安装open fire插件从openfire获取了History并尝试了这段代码。

I fetched History from openfire by installing open fire plugin in the open fire and tried this code.

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: "raman@ip-172-31-53-77.ec2.internal")
    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 )

现在我没有从双方获取历史记录。这是我得到的结果。

Now i am not getting history from Both Side. here is the result that i get.

<iq xmlns="jabber:client" 
type="result" 
id="0" 
to="bentick@ip-172-31-53-77.ec2.internal/5qsinh1syg">

<chat xmlns="urn:xmpp:archive" 
with="raman@ip-172-31-53-77.ec2.internal" 
start="2017-02-07T06:28:33.691Z">

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

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

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

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

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

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

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

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

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

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

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

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

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

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

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

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

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

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

这是RAMAN而不是BENTICk的所有消息,因为这两个用户在获取历史时参与聊天我只得到RAMAN的消息。不是BENTICk
如何从双方用户那里获取历史记录。

This is all the message of RAMAN not BENTICk as this two user involved in chatting while getting history i only get the message of RAMAN. not BENTICk How to get history from both side user.

请帮忙。

推荐答案

我已经实现了同样的方法来获取通过发送给定的iq
收发消息我得到了正确的结果。

I have implemented the same to get the Message to and from by sending the given iq And I am getting the proper result.

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="0544008296@192.168.2.181"><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="0509503847@192.168.2.181/Smack">
  <chat xmlns="urn:xmpp:archive" with="0544008296@192.168.2.181" start="2017-02-28T09:55:27.068Z">
    <from secs="0" jid="0544008296@192.168.2.181">
      <body>Hiii rajeev</body>
    </from>
    <to secs="52">
      <body>Hi
        How r u</body>
    </to>
   <from secs="15" jid="0544008296@192.168.2.181"><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="0544008296@192.168.2.181"><body>Good</body></from>
   <from secs="5" jid="0544008296@192.168.2.181"><body>Continue </body></from>
   <to secs="834"><body>Ok
    </body></to>
   <to secs="8"><body>Nice chat
    </body></to>
   <from secs="232" jid="0544008296@192.168.2.181"><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>

这篇关于在获取聊天记录时,我没有从Openfire获得两个用户历史记录的文章就介绍到这了,希望我们推荐的答案对大家有所帮助,也希望大家多多支持IT屋!

查看全文
登录 关闭
扫码关注1秒登录
发送“验证码”获取 | 15天全站免登陆