Home

Websocket + Tornado + Redis »

Published on August 17, 2010.

Here is a simple example of a Websocket + Tornado + Redis Pub/Sub protocol interaction. The principle is very simple: when your user loads the page, she is automatically added to a list of "listeners". An independent thread is running: it listens for messages from Redis with the subscribe command, and send a message through Websocket to every registered "listener". In this example, the user can send a message to herself with a simple AJAX-powered form, which calls a view with a payload (the message), and the view publish it via the publish command of Redis.

This is basically a web chat! If you want to have fun, you can then add a roster, with a presence system, authentication etc...