开发者

Comet JSON push to javascript

I've been learning Scala for a while on and off and have successfully got a simple real time post system up and running.

I was wondering if anyone out there could help me in the right direction to pushing data changes via JSON to several javascript modules I have running.

Basically what I'm looking for is a Comet system to push JSON data down to some page modules which will then accept the data and work out what to do with it.

For example, I have an html5 canvas which can be drawn upon. Each drawing is temporarily saved in JSON format with co-ordinates of the shape, color, thickness etc. This is then sent to the server to be distributed via Comet to the rest of the room participants.

I'm not really sure what to search for or even where to start looking for this kind of functionality.

Would it be best to save the开发者_JAVA百科 drawing in a DB and then Comet pick it up and pass it down to other people in the room?

Any help would be much appreciated, thanks in advance, and sorry if my question is vague, if so let me know and I'll happily expand on my explaination.

Cheers


This sort of use-case strikes me as one of the base use-cases for which Lift was implemented, so you might want to give the basic Chat example a look - http://simply.liftweb.net/index-Chapter-2.html#toc-Chapter-2

Make sure to look at the code on Github linked at the top of that page, because the text in the book doesn't provide all of the necessary pieces.

Regarding your last question, saving to a database is something you can do in parallel or in series with processing the comet requests. Best practice for saving to a database inside an actor is to farm the database access out to another actor so as not to block the process of the originating actor, but you can always refactor that DB access later if it becomes a problem.

0

上一篇:

下一篇:

精彩评论

暂无评论...
验证码 换一张
取 消

最新问答

问答排行榜