如何实现“最后一次看到"XMPP 中的功能(如 whatsapp)? [英] How to implement "last seen at" functionality (like whatsapp) in XMPP?

查看:23
本文介绍了如何实现“最后一次看到"XMPP 中的功能(如 whatsapp)?的处理方法,对大家解决问题具有一定的参考价值,需要的朋友们下面随着小编来一起学习吧!

问题描述

我正在开发一个聊天应用程序,想添加上次看到"功能.我正在尝试通过使用存在节来实现它,但遇到一个问题,请查看以下链接

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

当用户 B 也不可用时,不会让用户 A 不可用

有没有其他方法可以实现上次看到的功能

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='romeo@montague.net/orchard' 
    id='last1'
    to='juliet@capulet.com'
    type='get'>
  <query xmlns='jabber:iq:last'/>
</iq>

然后得到这样的回复:

<iq from='juliet@capulet.com' 
    id='last1'
    to='romeo@montague.net/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)?的文章就介绍到这了,希望我们推荐的答案对大家有所帮助,也希望大家多多支持IT屋!

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