问题描述
我正在开发一个聊天应用程序,想添加上次看到"功能.我正在尝试通过使用存在节来实现它,但遇到一个问题,请查看以下链接
I am working on a chat application and want to add "last seen at" functionality. I am trying to implement it by using presence stanzas but getting one issue, please check at below link
有没有其他方法可以实现上次看到的功能
Is there any other way to implement last seen at functionality
请推荐
推荐答案
xmpp last seen"的第一个 Google 结果是 XEP-0012: Last Activity,这是一个协议扩展,可用于查明用户上次在线的时间.
The first Google result for "xmpp last seen" is XEP-0012: Last Activity, which is a protocol extension that can be used to find out when a user was online last time.
您发送这样的请求:
<iq from='[email protected]/orchard'
id='last1'
to='[email protected]'
type='get'>
<query xmlns='jabber:iq:last'/>
</iq>
然后得到这样的回复:
<iq from='[email protected]'
id='last1'
to='[email protected]/orchard'
type='result'>
<query xmlns='jabber:iq:last' seconds='903'/>
</iq>
这意味着该联系人最后一次在线是在 903 秒前.从当前时间中减去此值以获得上次看到"时间戳.
Which means that the contact was last online 903 seconds ago. Subtract this from the current time to get the "last seen" timestamp.
这篇关于如何实现“最后一次看到"XMPP 中的功能(如 whatsapp)?的文章就介绍到这了,希望我们推荐的答案对大家有所帮助,也希望大家多多支持!