2

How can I possibly connect the players? How can I add a window wherein they can see each other like on the Tetris battle on Facebook?

I know some basic ajax polling. I am developing a Chess game.

Can this be possible on using jQuery/JavaScript?

Can anyone help me? I don't know where to start.

pimvdb
  • 151,816
  • 78
  • 307
  • 352
user1033600
  • 289
  • 4
  • 7
  • 17

3 Answers3

2

Use WebSockets. You will maybe need server-side JavaScript so use node.js for that.

noob
  • 8,982
  • 4
  • 37
  • 65
  • 1
    In no way does WebSockets require server-side JavaScript. It does require a server which somehow supports WebSockets. – Matt Ball Dec 17 '11 at 17:20
  • No but it requires a modern browser. – noob Dec 17 '11 at 17:22
  • And there are flash fallbacks for Websockets. Sweeet! You don't need Node, but it is very easy to use for Websockets. PHP for example isn't. – Rudie Dec 17 '11 at 17:25
2

You can do it using Web Sockets (an html5 feature).

Here's more info: How to Use Sockets in JavaScript\HTML?

And here's a cool library that uses it with a flash backup ( in case someone doesnt have an html5 browser)

http://socket.io/#faq

Community
  • 1
  • 1
Vigrond
  • 8,148
  • 4
  • 28
  • 46
  • Hey Flash fallback =) Websockets are fun. – Rudie Dec 17 '11 at 17:25
  • Flash isn't the only fallback that Socket.IO can use: http://socket.io/#browser-support – Matt Ball Dec 17 '11 at 17:25
  • 1
    +1 for socket.io. It does require node.js, but personally I find node.js a convenient environment to work in, more than PHP. – pimvdb Dec 17 '11 at 17:28
  • well, PHP is dead easy..where node.js requires a long learning-curve. I don't think it's worth learning just to socket communications. Things like this should take a day or two tops to make, not a month of boring study. – vsync Apr 29 '13 at 22:25
0

You included "mySql" in your tags. You could also use the "database" to communicate:

  1. Each "game" adds a new row

  2. A player's "move" updates the database (e.g. via an Ajax message)

paulsm4
  • 114,292
  • 17
  • 138
  • 190