Example Application: Collaborative Drawing

by Roberto SacconFebruary 4th, 2008

While looking for a JavaScript application that was easy to “Cometify” I discovered sketch, a Dojo example app recently committed by Liu Cougar. It fully implements the idea of pipelining the drawing process based on sequential commands for adding, modifying or deleting objects. It even implements an UndoStack, and is therefore perfectly suited for adding Comet-based collaborative drawing capabilities. But I didn’t want to start from scratch when adding that, so I took a chat application (which probably represents the “hello world” app of Comet) and wrapped it around the drawing app. At the basic level, the two application types are similar. With chat the sent objects are words, while with collaborative drawing the objects are drawing commands.

Very little additional code was necessary to combine the chat app and the drawing app into a collaborative example app. I added a single line of code to the drawing app to let it publish its drawing commands using Comet. Another line was added to the chat app for sending incoming drawing commands to the drawing application (any additional code only served to make things prettier, more readable, or easier to extend).

The application has been tested on ErlyComet, but there are no server-side dependencies, so in theory it should run equally well on any Bayeux-compliant Comet server. The source code is available on the ErlyComet website. And there is also a short screencast.

What is missing to make such an example application suitable for real life tasks? A lot, of course: the whole server-side logic, for one. And deciding (automatically or based on human interaction) which incoming changes should be applied to the master document (like conflict resolution in version control systems, just in quasi-real time). But as this example app demonstrates, once you have a Comet infrastructure in place there are applications which can be “Cometified” with little effort and huge results.

Comet Sketch

One Response to “Example Application: Collaborative Drawing”

  1. DylanSchiemann Says:

    It should be noted that the work on Sketch is possible because of the work done by TeamPatent. Very cool work Roberto!

Copyright 2015 Comet Daily, LLC. All Rights Reserved