关于XMPP跟openfire中的消息回执
关于XMPP和openfire中的消息回执
关于XMPP和openfire中的消息回执
1 协议层:
XMPP扩展协议已经定义了消息回执,参见 http://xmpp.org/extensions/xep-0184.html
XEP-0184: Message Delivery Receipts
XEP-0184 写道
The following is an example of a content message that includes a request for return receipt.
Example 3. A content message with receipt requested
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
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].
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].
2 实现层
openfire项目中,今年(2011)3月已经有人提交了此feature,参见 http://issues.igniterealtime.org/browse/OF-434
Add support for XEP-0184: Message Delivery Receipts
不过正如 wroot 对我的回复所述,此特性的release还遥遥无期:
wroot 写道
If nobody provides patches, probably never. We don't have active developers at the moment.
3 解决方案
- 如果可能,自己修改openfire,实现此特性即可。 其实难度不大,只是openfire是开源项目,多人异地协作,目前相对稳定,稳步发展;所以增加这种特性比自己实现还缓慢,需要有人推进才行。
- 曲线救国: 对于message消息,自己可以做一些私有的约定,比如服务器做一些响应,客户端额外发一些IQ等。
以上是两种思路,具体实现还要看产品或项目的具体需求,比如是否严格控制网络带宽,是否严格要求信息投递成功率等。