I want to start developing a browser game. Not for success, just for the sake of doing it and learning something from it.

Now, a point where I have serious problems figuring out how to deal with it is; how does one player receive message of another player does something that is somehow time-critical.

Easy example for a trading card game; Player 1 plays The devious flames of hell and Player 2 has to react to this card by playing Watery waves directly afterwards, before the card of Player 1 takes effect (so to say a counter-card).

Of course, I could just request the server every second and see if the other player did something, but I was hoping for a less request-frequent solution, like the server pushes the event of Player 1 playing a card to Player 2.

4 Answers
4

I just stumbled on this the other day -- check out NowJS at http://nowjs.com/ as I think it will give you a nice solution.

From the site...

NowJS creates a magic namespace "now",
accessible by server and client.
Functions and variables added to now
are automatically synced, in
real-time. Call client functions from
the server and server functions from
client