Client or server-side HTML5 canvas rendering for a node.js whiteboard application?


I was thinking a little whiteboard web app would be a nice way to improve my node.js and JavaScript skills. I've seen a few on the web, which makes sense as it seems ideal for this kind of stack.

Just taking a moment to think, however, I was wondering about the roles of both client and server in this kind of web application. Stumbling upon node-canvas, I became even more confused. What, specifically, should the client and server be responsible for?

If the server is capable of rendering to a canvas, should it accept and validate input from the clients and then broadcast it to all other connected users via This way, the server keeps a master-canvas element of sorts. Once a new user connects, the server just has to push out its canvas that client - bringing it up to pace with whatever has been drawn.

Any guidance on implementation - specific or philosophical - is appreciated.


8/31/2011 6:53:05 AM

I wrote, which uses node-canvas (previously node-cairo, which I wrote myself) along with

The way I've designed my application, the client essentially does all the stroke generation from user input. These are in turn processed by a canvas abstraction, which supports a subset of operations and parameters which I've defined myself. If this layer accepts whatever input the painting modules produce, they are also shipped, via, to the server.

On the server I've got the same kind of canvas layer wrapping node-canvas. This will thus replicate the input from the user in memory there, eventually making it possible to send a state image to new clients. Following this, the strokes will -- pending parameter / context validation by the server application -- be published to other connected clients, which will repeat the same procedure as above.

8/31/2011 8:03:05 AM

Licensed under: CC-BY-SA with attribution
Not affiliated with: Stack Overflow