Using WebSockets for multiplayer HTML5 games development. What to choose, Node.js, or Ratchet, or other?

bensampaio picture bensampaio · Dec 15, 2012 · Viewed 7.3k times · Source

I made some research before asking this question but I couldn't find a concrete answer for my situation. I'm still new to WebSockets and games development, so I may not be able to explain some parts very well and if that's the case please tell me so I can try to explain it better.

I'm currently developing a Web application using CakePHP, which will provide several kinds of HTML5 multiplayer games. On some situations those games will need to send data to a database. The problem is, I want to use Node.js to implement the game server side logic, but I'm not sure if I'll be able to pass data to the database. I think the best approach would be sending the data from Node.js to a PHP action that will then store it on the database, but I also don't know if that will be possible.

I found something about this DNode thing, but I'm not sure if this is the answer for my problem and besides that it seems to be in beta version, what I would like to avoid.

As an alternative, I thought about using Ratchet to implement the games server side logic. At least I know that I would be able to make it communicate with my application, but since I can't find any reference to it on games development I'm not sure if it's a good idea.

I don't know about any other frameworks, so if I have better options than those two, please tell me :)

Please give me your opinions. Thank you!

Answer

ElHacker picture ElHacker · Dec 15, 2012

I faced a similar problem a year ago trying to develop an online multiplayer game. I ended up using Node.js for the server and Socket.io for the Websockets

If you're new to Node.js I recommend you to read first this brief and good basic tutorial:

http://www.nodebeginner.org/

I use node.js everyday and I really find it very useful and productive. Once you're done reading the basics read this nice tutorial of developing multiplayer html5 games with node and sockets: http://smus.com/multiplayer-html5-games-with-node/

There is a link to an open source game at the end that might be helpful to you.

And you can check the socket.io docs here: http://socket.io/

Hope it helps so you can get started. That's the hardest part.