Shared Canvas and Chat
You will need an SVG capable browser for this example to work (e.g. firefox 1.5, browser + Adobe's SVG viewer, ...).
What you see is a very simple canvas which allows people to create a collaborative drawing. It is synchronised with the server everytime you draw something on it or after being idle for 5 seconds. When synchronized the canvas will submit newly added lines and update it's state with the one stored on the server.
You can also send a text to the canvas using the textbox below. (For now the sending of the text message does not update the canvas immediatly.)
The example is implemented using SVG for the canvas. For client server communication it uses json-rpc with a service implemented in python.
There are 3 methods the synchronization service provides:
- update(syncId, knownPathCount, newPathPoints) Adds the new points to the canvas state storage and returns a state object. The state object contains all paths the client needs to add to the canvas, all text and a new syncId and knownPathCount.
- clear() Clears the canvas state and returns a new syncId.
- addText(msg) Adds the text in msg to the text storage for the canvas.
The client periodically calls the update function of the service to either submit new paths or to update it's view of to the state of the canvas stored on the server.
