Reputation: 2476
I'm working on a web chat with xmpp. At the moment I used a long polling, but is it the best method to do it? the server side is in PHP, with other languages maybe there are better solutions but with PHP?
Upvotes: 1
Views: 897
Reputation: 2474
You can use web sockets
or server-side-events
. But these technologies only work for modern browsers.
Upvotes: 0
Reputation: 3028
This is a pretty common debate, and one to which there are numerous answers, dependent upon your server's capabilities and your constraints with licensing.
Essentially, the short answer right now is a library, like Node.js – this essentially handles the client-server relationship issues for you (determining availability of web sockets, flash, and falling back to AJAX long polling).
The long answer is that, with the state of browser adoption as it is, you have to account for numerous different contingencies – Do I want to require a technology, do I want to exclude certain groups, is it cost effective to develop a solution for groups X, Y, and Z? Then to cover all possibilities for the greatest efficiency server-side, you need to serve a sockets server of some kind, then client-side offer AJAX, Flash, and web sockets (possibly even Java to capture that last 1%). Ultimately, it boils down to who it's worth supporting (in an enterprise environment, you know the overall capabilities of the end users and can insist on one protocol; open web, you can't make those same assumptions).
Upvotes: 1