5
\$\begingroup\$

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.

\$\endgroup\$
1

4 Answers 4

3
\$\begingroup\$

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

\$\endgroup\$
2
  • \$\begingroup\$ Nice find. I wasn't even aware of Socket.IO. \$\endgroup\$ Jul 29, 2011 at 11:56
  • \$\begingroup\$ Is that limited to the amount of simultaneous connections you can have at once? \$\endgroup\$ Oct 26, 2012 at 11:24
1
\$\begingroup\$

You can also use long polling in HTTP with Redis, if you want to reduce the pulling on the server. The script essentially "listens" for the "broadcast" from your script.

\$\endgroup\$
0
\$\begingroup\$

"somehow time-critical" as in low latency?

WebSocket is the only way https://developer.mozilla.org/en/WebSockets

\$\endgroup\$
0
\$\begingroup\$

Try APE project

It's great for low-latency server pushing

\$\endgroup\$

You must log in to answer this question.

Not the answer you're looking for? Browse other questions tagged .