gpt4 book ai didi

xml - XMPP 中节 ID 的用途是什么?

转载 作者:数据小太阳 更新时间:2023-10-29 02:05:57 25 4
gpt4 key购买 nike

谁能解释一下 ID 在一些 XMPP XML 请求中的作用(谈论核心 XMPP)?

例如,我可以通过发送这个请求来获取花名册:

<iq type="get">
<query xmlns="jabber:iq:roster"></query>
</iq>

但我也可以通过添加一个随机 ID 来获取它:

<iq type="get" id="2346543">
<query xmlns="jabber:iq:roster"></query>
</iq>

是否有关于我应该或不应该使用 ID 的原因?与安全有关吗?有什么缺点吗?关于 ID 的约定是什么?应该如何构造它们?

最佳答案

我会建议简单地查看协议(protocol)规范。 RFC 6120 § 8.1.3. id恕我直言,解释得很好:

The 'id' attribute is used by the originating entity to track any
response or error stanza that it might receive in relation to the
generated stanza from another entity (such as an intermediate server
or the intended recipient).

It is up to the originating entity whether the value of the 'id'
attribute is unique only within its current stream or unique
globally.

For <message/> and <presence/> stanzas, it is RECOMMENDED for the
originating entity to include an 'id' attribute; for <iq/> stanzas,
it is REQUIRED.

If the generated stanza includes an 'id' attribute then it is
REQUIRED for the response or error stanza to also include an 'id'
attribute, where the value of the 'id' attribute MUST match that of
the generated stanza.

并不是说您的示例显示了没有设置“id”属性的 IQ 节实际上是无效

关于xml - XMPP 中节 ID 的用途是什么?,我们在Stack Overflow上找到一个类似的问题: https://stackoverflow.com/questions/54231270/

25 4 0
Copyright 2021 - 2024 cfsdn All Rights Reserved 蜀ICP备2022000587号
广告合作:1813099741@qq.com 6ren.com