views:

66

answers:

1

I'm using http://raphaeljs.com/ to draw some vector graphics on a canvas element on the page.

I want somehow to update the graphics on the page in realtime as events happen on another website i'm running.

For example, when someone uses the search facility on the other site, I want this to be represented on my canvas. Its a sort of event visualisation exersise. Different events will trigger the creation of different visuals on the canvas.

My problem is how do I structure the application. As far as I can tell there are two ways

  1. Keep the events in a database somewhere and have the canvas application query using ajax requests and add them to the page. (I see this PULL)

  2. Have the events send the data in some way to the canvas application which is listening for incoming requests (I see this as PUSH).

I would like to go with option 2 as I dont want to have to start storing things in databases and in turn then dealing with consuming the queue. I think it would be nicer to just send stuff to the canvas as it happens.

Does anyone have any advice on this, and how I might go about listening for incoming requests with JS. Is this even possible ?

+1  A: 

Sounds like you want to have a look at http://en.wikipedia.org/wiki/Comet_%28programming%29, a technology which allows a web server to push data to a browser.

andre-r