Official blog of Conversion Support

Main menu

Post navigation

ChannelAPI Comet Chat Demo on Google App Engine

A few days ago Google officially released App Engine SDK 1.4.0, which includes the Channel API. The ChannelAPI is Google’s solution to building real time Comet-enabled applications on Google’s App Engine infrastructure.

There is very little documentation at the moment regarding this new addition, so I put together a ChannelAPI demo.

The most popular comet demo has always been either the stock ticker demo or the chat demo. Considering that we are in the business of increasing sales and lowering shopping cart abandonment through chat and not financial planning, I opted to create the chat demo.

ChannelAPI Comet Chat Demo – Try it yourself

ChannelAPI Chat Demo Technical Information

To open a channel, the client page sends a request to the application server. This is called using a standard AJAX call to a servlet:

The channelId is returned in the response to the client page. The channelId key is used in the client-side code to open the socket with App Engine. The callback method invoked below demonstrates opening the socket to the App Engine Servers to initialize the comet connection.

// paste the message HTML into the document
$(this[‘selectors’].messages).append(messageElement);

// scroll the bar back to the bottom
$(this[‘selectors’].messages).animate({scrollTop: $(this[‘selectors’].messages)[0].scrollHeight});

},

The Bayeux protocol publish/subscribe model is used here to facilitate real time communication just as it has done in other implementations of Comet, such as Dojo’s Cometd. Additionally, since the WebSocket specification follows the same publish/subscribe methodology, hopefully it won’t be long before Google updates the ChannelAPI to use WebSockets in HTML5 compatible browsers while supporting Comet as a fallback in older browsers.

Real-time web applications are the future of application delivery. The days of boxed software and asking users to install your software are long gone. Technologies like Comet and the ChannelAPI will enable developers to build rich, Internet applications that are 100% browser based, require zero plug-ins, and require no software to install on the local machine.