您如何将 XMPP 绑定会话镜像到多个选项卡或窗口(如 facebook、okCupid 等)
我使用 http 绑定和 ejabberd 实现了基于 Web 的即时消息/聊天功能。对于懒惰的人来说,这是我的问题的简短版本:
您将如何实现一个基于 Web 的 XMPP 聊天客户端,该客户端可以同时显示在多个浏览器窗口中,每个窗口都显示打开聊天的相同视图?
对于那些关心的人来说更详细的漫谈:
一种潜在的解决方案是让每个选项卡管理它自己的连接。 XMPP 对多个客户端有足够的支持,所以让它来做路由。我对这个解决方案至少有两个问题。 1 是这会导致带宽消耗的明显增加。 2是目前ejabberd中不支持多个具有相同JID的客户端连接MUC房间。这显然会在 3.1 中实现,但对我来说这是一个主要问题。
最初我想知道是否涉及一些Flash魔法,但页面上的swf似乎只是用于播放通知音效。您可以通过使用 firebug 或类似工具删除嵌入标签来确认这一点。聊天功能仍然有效。
这基本上让我将 cookie 作为在选项卡之间共享的唯一方式。在这种情况下,主选项卡会将所有消息转储到可以从其他选项卡轮询的 cookie。这对我来说似乎很荒谬,因为轮询频率必须非常高才能避免任何延迟。当“主”窗口关闭时会发生什么?
我见过不止一个网站这样做,通常当我看到这样的问题时,我至少可以至少模糊地理解我会如何解决它,但我不介意承认这个问题让我难住了。
I've implemented a web based instant messaging / chat feature using http binding and ejabberd. For the lazy here's the short version of my question:
How would you go about implementing a web based XMPP chat client which could be displayed in multiple browser windows simultaneously, each displaying an identical view of the open chats?
More detailed ramblings for those who care:
One potential solution would be to just let every tab manage it's own connection. XMPP has decent enough support for multiple clients so let it do the routing. I have at least 2 issues with this solution. 1 is the obvious increase in bandwidth consumption this would cause. 2 is the current lack of support for multiple clients with the same JID to connect to MUC rooms in ejabberd. This will apparently be implemented for 3.1 but it's a major issue for me as it stands.
Initially I wondered if there might be some flash magic involved but it seems the swf on the page is only used to play the notification sound effects. You can confirm this by using firebug or similar to delete the embed tag. The chat feature still works.
This basically leaves me with cookies as the only way to share between the tabs. In this scenario a master tab would dump all messages to cookies which could be polled from other tabs. This seems quite ridiculous to me as the poll frequency would have to be exceptionally high to avoid any latency. What would happen when the 'master' window was closed?
I've seen this done by more than one site and normally when I look at problems like these I can at least understand at least vaguely how I'd go about it but I don't mind admitting this one has got me stumped.
如果你对这篇内容有疑问,欢迎到本站社区发帖提问 参与讨论,获取更多帮助,或者扫码二维码加入 Web 技术交流群。
绑定邮箱获取回复消息
由于您还没有绑定你的真实邮箱,如果其他用户或者作者回复了您的评论,将不能在第一时间通知您!
发布评论
评论(1)
因此,我在 Facebook 聊天中进行了更多研究,似乎他们只是让每个选项卡管理自己的连接。 Ejabberd 在我使用 MUC 房间实现这一目标的过程中设置了几个障碍,所以我想这就是为什么我最初倾向于打折这个解决方案的原因。我认为私人消息传递对于其他感兴趣的人来说应该更直接。
多个 MUC 实例的问题是 https://support.process-one.net/browse /EJAB-305
我想我必须为 ejabberd 打补丁。如果有人有任何其他意见,我很想听听。
So I've poked around in facebook chat a little more and it seems that they are just letting every tab manage it's own connection. Ejabberd puts several hurdles in my way to achieve this with MUC rooms so I guess that's why I was inclined to discount this solution initially. I think private messaging only should be more straightforward for anyone else interested.
The issue with multiple MUC instances is https://support.process-one.net/browse/EJAB-305
I guess I'l have to make a case for patching ejabberd. If anyone has any other observations I'd love to hear them.