关于XMPP和openfire中的消息回执和聊天状态
1 协议层:
XMPP扩展协议已经定义了消息回执,参见 http://xmpp.org/extensions/xep-0184.html
同样也定义了聊天状态,参见 http://xmpp.org/extensions/xep-0085.html
XEP-0184: Message Delivery Receipts
Example 3. A content message with receipt requested
<message from='northumberland@shakespeare.lit/westminster' id='richard2-4.1.247' to='kingrichard@royalty.england.lit/throne'> <body>My lord, dispatch; read o'er these articles.</body> <request xmlns='urn:xmpp:receipts'/> </message>
Note: A sender MUST include an 'id' attribute on every content message that requests a receipt, so that the sender can properly track ack messages.
The recipient shall generate an ack message if and only if (1) it supports the Message Delivery Receipts protocol and (2) it is configured to return receipts, either globally or for this recipient (otherwise it MUST NOT return a receipt and SHOULD NOT return an error).
Example 4. A message delivery receipt
<message from='kingrichard@royalty.england.lit/throne' id='bi29sg183b4v' to='northumberland@shakespeare.lit/westminster'> <received xmlns='urn:xmpp:receipts' id='richard2-4.1.247'/> </message>
When the recipient sends an ack message, it SHOULD ensure that the message stanza contains only one child element, namely the <received/> element qualified by the 'urn:xmpp:receipts' namespace. In addition, it SHOULD include an 'id' attribute that echoes the 'id' attribute of the content message. Naturally, intermediate entities might add other extension elements to the message when routing or delivering the receipt message, e.g., a <delay/> element as specified in Delayed Delivery [11].
XEP-0085: Chat State Notifications
Example 3. User Sends Initial Content Message With <active/> Notification
<message
from='bernardo@shakespeare.lit/pda'
to='francisco@shakespeare.lit'
type='chat'>
<body>Who's there?</body>
<active xmlns='http://jabber.org/protocol/chatstates'/>
</message>
Example 4. Contact's Client Sends Content Message Reply With <active/> Notification
<message
from='francisco@shakespeare.lit/elsinore'
to='bernardo@shakespeare.lit/pda'
type='chat'>
<body>Nay, answer me: stand, and unfold yourself.</body>
<active xmlns='http://jabber.org/protocol/chatstates'/>
</message>
Because the User now knows that the Contact supports chat state notifications, the User can send other notification types.
Example 5. User Sends Standalone <composing/> Notification
<message
from='bernardo@shakespeare.lit/pda'
to='francisco@shakespeare.lit/elsinore'
type='chat'>
<composing xmlns='http://jabber.org/protocol/chatstates'/>
</message>
Example 6. User Sends a Content Message Reply With <active/> Notification
<message
from='bernardo@shakespeare.lit/pda'
to='francisco@shakespeare.lit/elsinore'
type='chat'>
<body>Long live the king!</body>
<active xmlns='http://jabber.org/protocol/chatstates'/>
</message>
And so forth.
<active/> | User is actively participating in the chat session. | User accepts an initial content message, sends a content message, gives focus to the chat session interface (perhaps after being inactive), or is otherwise paying attention to the conversation. |
<inactive/> | User has not been actively participating in the chat session. | User has not interacted with the chat session interface for an intermediate period of time (e.g., 2 minutes). |
<gone/> | User has effectively ended their participation in the chat session. | User has not interacted with the chat session interface, system, or device for a relatively long period of time (e.g., 10 minutes). |
<composing/> | User is composing a message. | User is actively interacting with a message input interface specific to this chat session (e.g., by typing in the input area of a chat window). |
<paused/> | User had been composing but now has stopped. | User was composing but has not interacted with the message input interface for a short period of time (e.g., 30 seconds). |
The following figure attempts to capture the most common state transitions in visual form (all four of the states shown can also transition to the GONE state).
o (start) | | INACTIVE <--> ACTIVE <--> COMPOSING <--> PAUSED | | | | +---<---<---<---<---<---<---<---<---<---+
Note: Other transitions are not forbidden if the developers of an implementation feel that such transitions are desirable (e.g., INACTIVE to PAUSED if a user returns to a chat session interface containing an unfinished message).
2 实现层
openfire项目中,今年(2011)3月已经有人提交了XEP0184的feature,参见 http://issues.igniterealtime.org/browse/OF-434
Add support for XEP-0184: Message Delivery Receipts
不过正如 wroot 对我的回复所述,此特性的release还遥遥无期:
至于XEP-0085 ,目前主流的实现都是支持的 ,而且这个逻辑更多是在客户端,比较简单。
3 解决方案
- 如果可能,自己修改openfire,实现此特性即可;或者使用插件的方式去实现。 其实难度不大,只是openfire是开源项目,多人异地协作,目前相对稳定,稳步发展;所以增加这种特性比自己实现还缓慢,需要有人推进才行。
- 曲线救国: 对于message消息,自己可以做一些私有的约定,比如服务器做一些响应,客户端额外发一些IQ等。当然不太推荐这种方式。
以上是两种思路,具体实现还要看产品或项目的具体需求,比如是否严格控制网络带宽,是否严格要求信息投递成功率等。
消息回执和聊天状态都是用户体验相关的feature,所以需要在功能稳定和流量等因素许可的前提下去优化和改进。
同理,类似 geo-location 或 LBS 相关的feature,我们也可以自己去实现。
比如 openfireLBS 插件 https://github.com/node/openfireLBS
相关推荐
先说一下为什么要写这篇博客,是因为本人在周末在研究XMPP和OpenFire,从网上下载了个Demo,但跑不起来,花了很长时间,经改造后,跑起来了,写个篇博文也是希望后边学习XMPP和OpenFire的同学下载后直接运行,少走...
android studio 基于XMPP,Openfire,Smack聊天demo 基于openfire3.9.3
0.0.0 VScode插件platformIO开发环境的安装[esp32、8266]_̌萌新历险记的博客-CSDN博客.mhtml
五一数学建模
人工智能大模型体验报告3.0 目录 大模型产品测评综述 大模型产品现状与进程 3 .0版本大模型测评规则 大模型厂商整体测评 3.0版本大模型综合指数 3.0版本 测评细分维度指数及评述 测评题目展示 厂商最佳实践案例 厂商优秀案例展示 人工 智能大模型体验报告3.0.pdf (1.39 MB, 需要: RMB 9 元)
使用opencv进行人脸识别和对比-python源码.zip
触屏版自适应手机wap软件网站模板 触屏版自适应手机wap软件网站模板
基于matlab实现的GST模型的红外弱小目标检测代码.rar
LMDI(对数平均迪氏指数法)目前在能源消耗、碳排放等领域应用很多,总体来说并不 是一个很难的方法,但是相应的资料、步骤还是比较少。本人在写论文的时候,通过搜集资 料、研究,找到了stata的实现方法,来自于 Kerry Du老师写的一个模块l dmi,网址为: LMDI: Stata module to compute L ogarithmic Mean Divisia Index (LMDI) Dec omposition (repec.org) 大家可以自己去研究一下。对应的参考 文献就是Ang, B.W., 2005. The LMDI approach t odecomposition analysis: a practical gui de. Energy Policy 33, 867–871. 目前LMDI分解基 本都以这篇文献为参考,论坛里也有,大家可以下载去深入研究一下,总体并不难。 但是 对于LMDI方法的解读以及stata实现的步骤、过程,目前基本没有具体的中文资料 。 本文在写论文的过程中,进行了总结,现上传上来供大家参考,里面包括stata的 程序文件(ado
IEC 60695-11-2-2017 第11-2部分:试验火焰——1kW标称预混合火焰——装置、验证试验安排和指南.pdf
基于matlab实现的拉普拉斯金字塔分解 做毕业设计的可以参考,小波变换以及MGA的初级参考.rar
本文档是课题研究的研究报告内含调研以及源码设计以及结果分析
Node.js,简称Node,是一个开源且跨平台的JavaScript运行时环境,它允许在浏览器外运行JavaScript代码。Node.js于2009年由Ryan Dahl创立,旨在创建高性能的Web服务器和网络应用程序。它基于Google Chrome的V8 JavaScript引擎,可以在Windows、Linux、Unix、Mac OS X等操作系统上运行。 Node.js的特点之一是事件驱动和非阻塞I/O模型,这使得它非常适合处理大量并发连接,从而在构建实时应用程序如在线游戏、聊天应用以及实时通讯服务时表现卓越。此外,Node.js使用了模块化的架构,通过npm(Node package manager,Node包管理器),社区成员可以共享和复用代码,极大地促进了Node.js生态系统的发展和扩张。 Node.js不仅用于服务器端开发。随着技术的发展,它也被用于构建工具链、开发桌面应用程序、物联网设备等。Node.js能够处理文件系统、操作数据库、处理网络请求等,因此,开发者可以用JavaScript编写全栈应用程序,这一点大大提高了开发效率和便捷性。 在实践中,许多大型企业和组织已经采用Node.js作为其Web应用程序的开发平台,如Netflix、PayPal和Walmart等。它们利用Node.js提高了应用性能,简化了开发流程,并且能更快地响应市场需求。
制造企业数字化转型ERP与CRM系统集成定位及场景构建方案.pptx
触屏版自适应手机wap软件网站模板 触屏版自适应手机wap软件网站模板
【课程设计全套资料】基于JAVA的管理系统
IEC 60730-2-13-2017.pdf
机械设计谷物洗涤机sw12非常好的设计图纸100%好用.zip
2000—2022年东中西分区域空间权重矩阵,省级层面,具体包括01矩阵,经济矩 阵,地理矩阵,经济地理矩阵以及经济地理嵌套矩阵,包含原始数据和计算过程,经济地理 权重矩阵采用2000-2022年数据,可以更改研究期间,里面有计算过程,地理距离 是用的欧式距离,如有疑问可与我私聊哈,大家放心下载。
TMCM-0930-TMCL 硬件手册