noway Posted April 12, 2016 Share Posted April 12, 2016 Hi, As a learning project I'm going to build a clone of the game agar.io with Phaser. Do you have any recommendation for the multiplayer aspect of the game? Which framework should I use? socket.io, eureca.io, something else? What are the pro/cons of each framework? Thanks! Link to comment Share on other sites More sharing options...
mattstyles Posted April 12, 2016 Share Posted April 12, 2016 There have been a few of these posts recently, if you search the forums you might find some more helpful stuff for you. There's nothing specifically in Phaser. I have a fair amount of experience with socket.io and its generally pretty solid, plus the api is decent and very clean. Link to comment Share on other sites More sharing options...
WombatTurkey Posted April 12, 2016 Share Posted April 12, 2016 I recommend this Websocket Library: https://github.com/websockets/ws with Nodejs as your backend. You can easily scale later with Redis and utlizing PM2. And obviously using the binary protocol would be ideal. Link to comment Share on other sites More sharing options...
noway Posted April 12, 2016 Author Share Posted April 12, 2016 6 hours ago, WombatTurkey said: I recommend this Websocket Library: https://github.com/websockets/ws with Nodejs as your backend. You can easily scale later with Redis and utlizing PM2. And obviously using the binary protocol would be ideal. What's the differance between socket.io and this libraby? Link to comment Share on other sites More sharing options...
WombatTurkey Posted April 12, 2016 Share Posted April 12, 2016 1 hour ago, noway said: What's the differance between socket.io and this libraby? 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. Link to comment Share on other sites More sharing options...
noway Posted April 12, 2016 Author Share Posted April 12, 2016 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 More sharing options...
WombatTurkey Posted April 12, 2016 Share Posted April 12, 2016 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! Link to comment Share on other sites More sharing options...
mattstyles Posted April 13, 2016 Share Posted April 13, 2016 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. drhayes and Boz 2 Link to comment Share on other sites More sharing options...
drhayes Posted April 13, 2016 Share Posted April 13, 2016 +1 for Browserquest as an example. ( = Link to comment Share on other sites More sharing options...
kevdude Posted April 18, 2016 Share Posted April 18, 2016 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 Boz 1 Link to comment Share on other sites More sharing options...
rgk Posted April 18, 2016 Share Posted April 18, 2016 I like primus.io so I can pick which library I want/need to use. 90% of the time its ws. Link to comment Share on other sites More sharing options...
Recommended Posts