在我的网络服务器上实施实时聊天系统的最佳方法是什么?
我对基于 Jabber 的东西感兴趣,但我没有找到免费/开源的东西,所以我正在考虑写一个。
我已经安装了 Jabber 服务器,现在正在考虑如何编写客户端。我正在考虑这两种方法之一。
1) 对 web 服务器上运行的 jabber 脚本进行 ajax 调用,负责连接到服务器。但后来我想到,由于 jabber 客户端涉及的依赖关系,当几个客户端连接时,它可能最终会消耗太多内存。
2) 另一种方法是运行一个作为守护进程运行的客户端,负责处理所有繁重的工作。这样,我只需要一个发送欺骗消息的客户端实例(发件人的名称就是用户在网站上输入的名称)。在网络服务器上运行的一个简单脚本通过某种 API(也许是 XMLRPC 或 Msgpack?)与该守护进程进行对话,
我认为 #2 更好,但我不确定。我还有其他方法可以实现这一点吗?我正在考虑为此使用 Perl 或 Python。
I'm interested in something based on Jabber but I didn't find a free/opensource one so I'm thinking of writing one.
I've installed a Jabber server and now thinking about the ways in which I can write the client. I'm thinking of one of either these two methods.
1) An ajax call made to a jabber script running on the webserver that takes care of connecting to the server. But then I thought because of the dependencies involved in the jabber client, it might end up consuming too much memory when a few clients connect.
2) The other method is to run a client running as a daemon that takes care of all the heavy lifting. This way I need to have only one instance of the client that sends a spoofed message (sender's name as that of whatever the user entered on the site). A simple script running on the webserver talks to this daemon over some sort of API (XMLRPC or Msgpack maybe?)
I think #2 is better but I'm not sure. Are there other ways I can implement this? I'm considering using Perl or Python for this.
如果你对这篇内容有疑问,欢迎到本站社区发帖提问 参与讨论,获取更多帮助,或者扫码二维码加入 Web 技术交流群。
绑定邮箱获取回复消息
由于您还没有绑定你的真实邮箱,如果其他用户或者作者回复了您的评论,将不能在第一时间通知您!
发布评论
评论(2)
Jabber 现在通常称为 XMPP,有数十种客户端和服务器,适用于每种语言。如果您使用 Javascript(您提到 Ajax),您可能需要 Strope。大多数服务器都是模块化的,因此您只需加载所需的功能(考虑 Tigase、ejabberd 或 xmpppy)。自己写一个想法比听起来更糟糕。
Jabber is usually called XMPP nowadays, and there are dozens of clients and servers, something for every language. If you are using Javascript (you mention Ajax), you probably want Strophe. Most servers are modular, so you only load the features you need (consider Tigase, ejabberd, or xmpppy). Writing your own is even worse an idea than it sounds.
BOSH
Node.js
或者您可以考虑安装 node.js 以使用 socket.io 创建聊天系统。
BOSH
Node.js
Or you could consider installing node.js to create your chat system using socket.io.