views:

203

answers:

2

Hi all,

I will probably use javascript to develop an online board/card game. My approach will be to have a client that will be able to work in standalone mode, so it must enforce rules. That means for example, if a player can't play a card, he or she shouldn't even be able to play it. This is to enhance the user experience.

The idea here is to add hooks to send and receive events to and from the server, and share the code that implements the game rules between the server and the client. I don't see the point of writing them twice.

So, if I play in "server" mode, the client will update the server with my actions (verifying them as well), and the server will send me updates about the rest of the players.

Is there any framework to leverage this work?

For the server side, my options seem to be Node.js (unstable, but everything would be JS and that's neat), Erlang + erlang_js, and maybe some of those weird frameworks that "compile into javascript", that I'm no really fond of.

Thanks in advance.

+1  A: 

Sounds like Ape fits your requirements rather closely. It supports javascript modules so you can run the same code on the server as you use for clients and sending messages between different users is well supported (check out the mmorpg and chat demos).

phyrex1an
Very nice! I didn't knew about Ape. I don't know if I am going to use it but I think this leads me in the right direction, thanks a lot!
codecaster
Unfortunately APE (which is neat) is only for pushing stuff for clients.
codecaster
A: 

I've been using RingoJs http://ringojs.org for exactly this - client&server code sharing - for a while.

For writing networked browser games easier i'm developing a thin layer on top of that: http://gamejs.org

oberhamsi