问题
I developed a Facebook-like chat in PHP and JavaScript. It's a plugin for a forum software. Currently I'm using (short) polling to receive new messages, but I'd like to try it with something better, like sockets.
What would you recommend for this kind of chat (available on every site, private chat, group chat..) : WebSockets, node.js with socket.io, ejabberd...
回答1:
From my personal experience there are no good socket library available for PHP. Usually one wants to have a socket library which will have fallback mechanisms if native socket support is not available. 2 suggestions from me :
- Switch completely to node.js + Socket.io solution, discard PHP.
- Have a nodejs + socket.io chat system running as a separate server along with PHP. Put HAPROXY in front of your webserver. Divert all socket request to node.js and all other request to PHP. In this way you will be able to use the goodies of both node.js and PHP.
I had a similar situation and I am using option 2 :).
来源:https://stackoverflow.com/questions/10885445/backend-server-software-for-facebook-like-chat-with-php-mysql-js