保留 XMPP 连接

发布于 2024-09-24 18:21:44 字数 161 浏览 0 评论 0原文

我有一个 GChome 扩展来监听 XMPP 服务器。 我使用 Strope 进行 BOSH 连接。 问题是“我应该如何处理连接?”从 XMPP 核心 wiki 中,我发现最后一个连接/优先的客户端接收消息。当用户从其他地方登录时,分机将停止接收消息。我该如何管理这种连接缺失。我希望这个问题不是很含糊=)。

I have a GChome extension that listens to XMPP server.
I use Strophe for BOSH connection.
The issue is "how should I handle connection?" from the XMPP core wiki, I found that the last connected/prioritized client receives messages. And when user is logged in from other place Extension stops receiving message. How can I manage this connection absence. I hope the question is not very ambiguous =).

如果你对这篇内容有疑问,欢迎到本站社区发帖提问 参与讨论,获取更多帮助,或者扫码二维码加入 Web 技术交流群。

扫码二维码加入Web技术交流群

发布评论

需要 登录 才能够评论, 你可以免费 注册 一个本站的账号。

评论(1

梓梦 2024-10-01 18:21:44

确保为每个连接使用不同的资源。最简单的方法是让服务器生成资源名称,如 RFC 3920bis,第 7.5 节,通过让您的客户端发送:

<iq id='tn281v37' type='set'>
  <bind xmlns='urn:ietf:params:xml:ns:xmpp-bind'/>
</iq>

并观察服务器以完整生成的 Jabber ID 进行响应:

<iq id='tn281v37' type='result'>
  <bind xmlns='urn:ietf:params:xml:ns:xmpp-bind'>
    <jid>
      [email protected]/4db06f06-1ea4-11dc-aca3-000bcd821bfb
    </jid>
  </bind>
</iq>

请记住,服务器可能会强制执行最大数量的资源,所以你可能会得到一个错误:

<iq id='wy2xa82b4' type='error'>
  <error type='wait'>
    <resource-constraint
        xmlns='urn:ietf:params:xml:ns:xmpp-stanzas'/>
  </error>
</iq>

Make sure you use a different resource for each connection. The easiest way to do this is to have the server generate the resource name, as specified in RFC 3920bis, section 7.5, by having your client send:

<iq id='tn281v37' type='set'>
  <bind xmlns='urn:ietf:params:xml:ns:xmpp-bind'/>
</iq>

And watching for the server to respond with the full generated Jabber ID:

<iq id='tn281v37' type='result'>
  <bind xmlns='urn:ietf:params:xml:ns:xmpp-bind'>
    <jid>
      [email protected]/4db06f06-1ea4-11dc-aca3-000bcd821bfb
    </jid>
  </bind>
</iq>

Keep in mind that the server may enforce a maximum number of resources, so you might get an error:

<iq id='wy2xa82b4' type='error'>
  <error type='wait'>
    <resource-constraint
        xmlns='urn:ietf:params:xml:ns:xmpp-stanzas'/>
  </error>
</iq>
~没有更多了~
我们使用 Cookies 和其他技术来定制您的体验包括您的登录状态等。通过阅读我们的 隐私政策 了解更多相关信息。 单击 接受 或继续使用网站,即表示您同意使用 Cookies 和您的相关数据。
原文