2008-05-07

Google App Engine: Ytalk like multiuser chat

This is a follow up on my last post describing missing services for AppEngine.

The idea is to help developers writing apps for AppEngine by providing them some common functionality missing and impossible to have on AppEngine and offer them as external services.

These services are accessible through a simple API over HTTP, and it is easy to call them from AppEngine applications using urlfetch methods.

The services available now are image resizing and comet.

Image resizing is built around a work queue, to which you can POST resize requests with a URL that will be called back when the resize is finished.

The comet service is much more interesting. It is a standalone comet server with properly implemented long running requests (not cheating with constant polling by the client) and allows many to many conversations using channels/chat rooms.

The comet server can notify your AppEngine application when users enter or leave channels, so your app can display updated presence info.

But the conversation can be going directly between client browsers and comet server, so it doesn't eat the precious AppEngine traffic limits.

As a demo of the comet server I have written a chat application modeled after an old-school unix program called ytalk.

The unique feature of the ytalk implementation is that it sends messages after every keystroke, rather than after end of line. That way you can see words not only being written, but being deleted too, letter by letter. It is quite funny to watch it specially when you realize the amount of all the HTTP traffic that happens in the background.

The biggest challenge is to maintain high speed of sending updates, which depends on the connection latency and on the speed of our server. The server is event driven, and is mainly multiplexing streams of bytes flowing through file descriptors, so the overhead here is small.

Summing up
Anyway, the point I want to stress is easy integration with external application. You can write your app in any framework and use the comet server as a service (via HTTP requests used only for control).

The service doesn't require any proxy server, as it is sometimes used in similar setups.

Of course the services are still in development, call it experimental version.


Here you can see my demos of AppEngine apps using the described services.

You can test the ytalk example, or take look at the video to see it in action (yes, in the movie there are two different browsers opened: left is firefox, right is opera):



No comments: