设置BOSH以允许用户长时间无需密码登录?

发布于 2024-09-18 20:45:57 字数 92 浏览 1 评论 0原文

我只是想知道如何在不损坏 BOSH 的情况下进行设置。我有 sid、rid 和一切,但我想知道我可以在 cookie 的时间内自动让人们登录多长时间,以及这是如何实现的。

I'm just wondering how one could set this up without the BOSH dying. I have the sid, rid, and everything but I was wondering how long i could automatically log people on for the time of lets say a cookie and how is this achieved.

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

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

发布评论

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

评论(2

豆芽 2024-09-25 20:45:57

您的答案取决于 BOSH 会话超时所需的时间。通常需要 60 秒才会丢弃会话。

请注意 - 您可能想要自动登录用户,因为正确的 XMPP 流程尚未完成。这是一个典型的流程:

->登录并建立 BOSH 会话。

->发送状态
--->服务器发送<存在/>>向您名册中的所有实体发送数据包,通知他们您有空。
--->服务器向名册服务器中的所有实体发送存在探测,获取它们当前的可用性。
<- 状态数据包如雨点般降临到您的会话中。

->请求名册项目
<- 服务器向您发送名册中的项目列表。

通过使用同一会话的方法,您可以跳过所有这些初始化,我认为这对您的应用程序很重要,因为您将不会获得任何实体的存在,直到它们更改其存在。发送另一个<存在/>> stanza 不会不会向您发送名册中每个人当前的状态。所以...如果这对你来说不重要,那就去做吧。我只是在您实施该方案并发现您的解决方案存在一些注意事项之前提供一些有用的信息。

对我们有用的是使用 localStorage,并通过“保存我的密码”按钮自动登录。这使得它更简单,工作量更少。此外,当用户重新加载页面并自动重新登录时,与用户关闭页面并在 5 分钟内返回并看到登录页面时相比,这可能会令人困惑。这简直令人困惑。

祝你好运!

Your answer depends on how long it takes for your BOSH session to timeout. It's usually 60 seconds until it throws away the session.

Just a note- you probably do not want to automatically log in a user, since the proper XMPP flow is not done. Here's a typical flow:

-> Login and establish a BOSH session.

-> Send Presence
---> Server sends a <presence/> packet to all entities in your roster, notifying them that you are available.
---> Server sends a presence probe to all of the entities in your roster's server, getting their current availability.
<- Presence packets come raining down on your session.

-> Request roster items
<- Server sends you a list of items in your roster.

With the approach of using the same session, you skip all of this initialization, which I assume is important to your application, as you will not get presence of any entities until they change their presence. Sending another <presence/> stanza will not send you the current presence of everyone in your roster. So... if that isn't important to you, go ahead and do it. I'm just providing some useful information before you go and implement the thing and find out that there are caveats to your solution.

What worked for us was to use localStorage, and automatically log them in via a "Save my password" button. That makes it simpler and less work. Also, it can be confusing when a user reloads the page and they get logged back in automatically, versus a user closing the page and coming back in 5 minutes to be greeted by the login page. It's just plain confusing.

Good luck!

甜是你 2024-09-25 20:45:57

您可以根据需要和方便执行以下操作之一:

  1. 通过 cookie 自动检测用户登录状态。执行 http 预绑定并向用户发出新的rid/sid。这通常对页面上的用户是透明的。
  2. 您可以池化底层 xmpp tcp 流,而不是在每个页面刷新/重新加载时发出新的“sid”,这在高流量下可能会非常昂贵。下次当用户需要 sid/rid 重新启动时,可以从连接管理器池中获取这些会话。

You can do one of the following as per your need and convenience:

  1. Auto detect about user login status via cookies. Do an http-pre-bind and issue new rid/sid to the user. This will generally be transparent to user on your page.
  2. Instead of issuing new "sid" on every page refresh/reload which can be quite expensive under high traffic, you can pool the underlying xmpp tcp streams. Next time when a user need sid/rid to start again, these can be fetched from the connection manager pooling the sessions.
~没有更多了~
我们使用 Cookies 和其他技术来定制您的体验包括您的登录状态等。通过阅读我们的 隐私政策 了解更多相关信息。 单击 接受 或继续使用网站,即表示您同意使用 Cookies 和您的相关数据。
原文