oakmac / chessboardjs

JavaScript chessboard
https://chessboardjs.com
MIT License
2.01k stars 408 forks source link

Question : how to make a real time game for 2 players #107

Closed tbonnechere closed 8 years ago

tbonnechere commented 9 years ago

Hi, I am a student in second year of university. Last year I had a project which was to develop a first website. I used Wordpress and your chessboardjs. 2 players can play the game. The dashboard is displayed on a page. Each game is a post. Each time the user drop the piece the fen is refreshed and saved on post meta. It is working but to make the opponent able to see the movement the page is refreshed every x seconds. I'd like to know if there is another way to use your chessboardjs and make it live to allow players to see the movement in real time?

I read few things on websocket. Is this a free solution (a student project) ? I do understand I have to install some node.js... buy an IP address. Do you know a free solution that is working with wordpress ?

Best regards, Thierry

vincaslt commented 9 years ago

Wordpress is first and foremost a CMS for blog sites. It has, however, advanced to the point that it's possible to make bigger and more complex web sites. And what you are doing is possible, but in my opinion very inefficient. I don't know much about wordpress' internals, but it's written in php and you will most likely have to write your own plugin for it. It was not made with realtime web applications in mind, and I'd recommend writing the system that you want yourself.

For a real-time game php is a bad choice. You could take advantage of javascript and ajax, for most basic use, jQuery could be sufficient. However HTTP requests in essence are not fit for the thing that you are trying to do. You are better off using node.js and sockets for that, or any other server solution that is based on or can use sockets. However I do recommend node.js.

The task is interesting and not extremely hard, but not quite as easy as just plugging in wordpress and dropping a chessboardjs library in...

davidmpaz commented 9 years ago

Hi,

Please don't take it as an advertisement :) .... but if you feel in the mud, take a look here, it is quite old code, not touch since long time, but it could be used for your project.

Cheers