设置BOSH以允许用户长时间无需密码登录?
我只是想知道如何在不损坏 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 技术交流群。
绑定邮箱获取回复消息
由于您还没有绑定你的真实邮箱,如果其他用户或者作者回复了您的评论,将不能在第一时间通知您!
发布评论
评论(2)
您的答案取决于 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!
您可以根据需要和方便执行以下操作之一:
You can do one of the following as per your need and convenience: