Jump to content

Best framework to do a multiplayer game with Phaser?


noway
 Share

Recommended Posts

2 minutes ago, WombatTurkey said:

WS claims to be the fastest. And with the WS module you don't need to include https://cdn.socket.io/socket.io-1.4.5.js. I guess socket.io is fine if that kind of stuff doesn't bother you, and are looking for more of an easier API.

This will be my first multiplayer project, so I'm looking for something simple! So socket.io is a better choice then?

Link to comment
Share on other sites

1 hour ago, noway said:

This will be my first multiplayer project, so I'm looking for something simple! So socket.io is a better choice then?

Probably! They have tons of tutorials as well and their API is easy!  Sorry for mentioning the ws library ha, but I mean, it's really simple too! :P

Link to comment
Share on other sites

WS is a very low-level implementation, infact socket.io is built on top of ws (socket.io uses engine.io as its transport mechanism, which is basically a slightly modified version of ws).

ws allows you to just send and receive text or binary messages and nothing much else. socket.io builds on top of that by adding a messages routing protocol (its api is extremely similar to most eventemitter implementations) and adds stuff like rooms and namespaces. Both support binary, ws has less going on so messages are a little lighter.

The difference in api in code is this:

// ws
ws.send( 'message' )

// socket.io
socket.send( 'event', 'message' )

In this case only socket instances specifically listening for the 'event' message will fire, whereas all listeners will fire for ws. Of course, you could add you own routing protocol very easily so its up to you how you want to deal with it.

I've written wrappers for both libraries, socket.io has more features but ws has less abstraction.

Some good resources for you 

Websocket Guide - a little old now but a good overview of how websockets work and how you can work with them.

Browserquest - again, a little old, and pretty low level but its bloody handy to have a fully working game to pick apart.

Architecture - comprehensive overview of one way of coding this all up.

Optimisation - from the same site again, and slightly out of date (socket.io now supports binary) but covers things you will need to consider eventually.

Link to comment
Share on other sites

I personally use the WS library for NodeJS. I first used socket.io and tried to host it on both openshift and heroku but socket.io seemed to not support websockets and would fall back to XHR polling, which is slow. The WS library in my opinion is very fast, and the only downside is that you have to program an event handler, which you can find a great tutorial for here

Link to comment
Share on other sites

 Share

  • Recently Browsing   0 members

    • No registered users viewing this page.
×
×
  • Create New...