What is the best way to implement a chat system on my web server?

I am interested in something based on Jabber, but I have not found a free / openource, so I am thinking of writing it.

I installed a Jabber server and now think about how I can write a client. I think of one of these two methods.

1) Ajax call made on a jabber script running on a web server that takes care of connecting to the server. But then I thought that due to the dependencies associated with the jabber client, it might end up consuming too much memory when connecting multiple clients.

2) Another method is to start a client working as a daemon that takes care of all the hard work. Thus, I need to have only one client instance that sends a fake message (the name of the sender as the name that was entered by the user on the site). A simple script running on a web server communicates with this daemon over some kind of API (perhaps XMLRPC or Msgpack?)

I think # 2 is better, but I'm not sure. Are there other ways to implement this? I am considering using Perl or Python for this.

+4
source share
2 answers

Jabber is usually called XMPP nowadays, and there are dozens of clients and servers, something for each language. If you use 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 an even worse idea than it sounds.

+3
source

Bosh

  • Install prosody because it is really installed on eaSily and has BOSH built-in support. You can skip this, but then you need to figure out how to use BOSH through ejabberd.
  • use strophe.js to implement this (using BOSH). New browsers support cross-domain request ( CORS → read without BOSH proxy). In older browsers, you can use a proxy server or use flash as a proxy server.
  • read Professional XMPP Programming with JavaScript and jQuery for the stanza. It even has chapters explaining how to create chats.

Node.js

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

+1
source

Source: https://habr.com/ru/post/1335673/


All Articles