|By Frank Salim||
|December 16, 2008 10:12 AM EST||
Chat rooms and live peer-to-peer chat on the web are high on the list of stunning rich application features that can still drop jaws. Facebook recently launched an integrated web chat implementation to much fanfare. Their impressive Erlang and C++ chat infrastructure showcases real-time web techniques and live, interactive interface elements. However, following Facebook's lead is actually not that hard if you use the right approach.
The two main difficulties faced by Facebook, Google, or any other web giant that wishes to deploy a chat application are scaling out an inconceivably large messaging back end and sending real-time messages to the browser. The first problem is one that many of us would like to have, but few actually encounter. The second problem is getting much, much easier to solve. Web chat is about to go mainstream, thanks in large part to a new HTML 5 feature called Web Sockets.
Chat Is Full-Duplex; the Web Is Not
The challenges in bringing real-time messaging (chat, for example) to web applications stem from the fundamental design of the web. It is, after all, a system designed for navigating hypertext documents. The request-response model is perfect for document retrieval, but it's less perfect for an application platform. Some applications are exceptionally bad fits.
Chat requires full-duplex communication. That is, data must be able to flow bidirectionally. This is a clear necessity for chat, as messages may originate on either the server or the client and must be transmitted without delay. After all, instant messaging is of little use if it isn't instantaneous. HTTP explicitly eliminates the ability to send information over the network in either direction at will at the same time.
Since nearly anything is possible, some tenacious developers have shoehorned full-duplex communication into existing web browsers. Comet long-polling, iframe streaming, and other techniques have all been applied in pursuit of this goal. Each technique has weaknesses, however, and even Comet techniques that allow data to stream down from the server cannot avoid initiating a new request for each upstream message. While a new request might not seem like much, each HTTP action causes several hundred bytes of header data to be generated, transmitted, and parsed. Even when bandwidth and computing resources are cheap, the additional latency incurred by a full round trip hurts real-time interactivity.
Using today's browser technology for both upstream and downstream, there is significant overhead to real-time communication. Despite this, some have been willing to stomach the complexity and inefficiency to run applications like chat on the web without succumbing to the temptation of proprietary plugins.
HTML 5 Web Sockets
The HTML 5 standard specifies new APIs for storage, drawing, drag-and-drop, and other areas that have made web programming painful. Browsers have already begun incorporating parts of HTML 5 (canvas, for example) even though the specification is far from complete. The HTML 5 Communication section includes two additional connectivity features: Server-Sent Events, a standardization of HTTP push, and Web Sockets, a cross-domain safe, full-duplex connection. Server-Sent Events will make real-time updates and notifications easy, and Web Sockets provide the functionality necessary to build chat for the web without the previously required hackery.
|393rocker 11/02/09 10:02:00 AM EST|
do u have a source code of implementing IM? if i start from the scratch..
Aug. 28, 2016 03:15 PM EDT Reads: 3,473
Aug. 28, 2016 03:00 PM EDT Reads: 721
Aug. 28, 2016 01:45 PM EDT Reads: 3,645
Aug. 28, 2016 01:00 PM EDT Reads: 2,409
Aug. 28, 2016 12:15 PM EDT Reads: 834
Aug. 28, 2016 11:45 AM EDT Reads: 666
Aug. 28, 2016 11:30 AM EDT Reads: 1,943
Aug. 28, 2016 11:00 AM EDT Reads: 674
Aug. 28, 2016 11:00 AM EDT Reads: 3,115
Aug. 28, 2016 10:45 AM EDT Reads: 839
Aug. 28, 2016 10:30 AM EDT Reads: 4,019
Aug. 28, 2016 10:30 AM EDT Reads: 882
Aug. 28, 2016 09:30 AM EDT Reads: 718
Aug. 28, 2016 09:30 AM EDT Reads: 764
Aug. 28, 2016 07:30 AM EDT Reads: 787