简体   繁体   中英

What's the best way to implement a Live chat system on my webserver?

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.

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

  1. Install prosody because it is really eaSily installed and has BOSH support built-in. You could skip this but then you need to find out how to use BOSH via ejabberd.
  2. use strophe.js to implement this(using BOSH). New browsers support cross-domain request( CORS -> read Proxy-less BOSH part). The old browsers you could use proxy or use flash in the middle as proxy.
  3. read Professional XMPP Programming with JavaScript and jQuery to learn strophe. It even has chapters explaining how to create chat.

Node.js

Or you could consider installing node.js to create your chat system using socket.io .

The technical post webpages of this site follow the CC BY-SA 4.0 protocol. If you need to reprint, please indicate the site URL or the original address.Any question please contact:yoyou2525@163.com.

 
粤ICP备18138465号  © 2020-2024 STACKOOM.COM