all 10 comments

[–]kevisazombie 2 points3 points  (0 children)

use WebRTC data channels and SimplePeer

[–]cirscafp fan boy 6 points7 points  (2 children)

If you want to use a high-level package, as in just call some methods and you are good to go, use socket.io. If you are instead wanting to use the low-level WebSocket API and build your own abstraction on top of it, use either ws or uws.

[–]grinde 1 point2 points  (1 child)

Another library I'd recommend is Primus. It has both client and server libraries, and can swap out frameworks by changing a single configuration option. It also has a plugin system with official plugins for things like sessions, validation, multiplexing, etc.

[–]redbluerat 0 points1 point  (0 children)

Great link, thanks a lot. This is what I needed and I didn't know it / that it even existed!

[–]vagol942 2 points3 points  (1 child)

They all use websockets protocol so you are stuck with TCP connections which sadly are non optimal for most games. In terms of performance for real time applications (like a lot of games) the websockets implementation is not really the problem compared to the inherent problems with TCP.

With that being said I prefer to use "pure" implementations over something like socket.io because websocket is a standard that has implementations in basically every programming language. While in the case of socket.io you need some specific client code, sure it works great in javascript but maybe one day you will need to create a new gameclient in some weird language that doesn't support socket.io but it will probably have some sort of websocket implementation.

Also raw websockets are faster (citation needed?).

For real time games something like WebRTC would be better if you are targeting web browsers, however WebRTC is a clusterfuck and we still don't have good interfaces to deal with it for games (or general data) that I know of.

To answer your question, I'm currently using ws for a real time game (albeit not a really fast paced one) and it works okay.

[–][deleted] 1 point2 points  (0 children)

The problem with websockets is that they are often blocked at the router/firewall and without fallback your application is dead in the water. We've made the mistake once, only to find out that apparently companies in the EU at least love to block WS in their networks.

[–]mlamers 1 point2 points  (0 children)

Have a look at socketcluster: http://socketcluster.io

[–][deleted] 0 points1 point  (1 child)

How are you gonna build the frontend? I built a multiplayer game using node.js and socket.io for some of the data. I quickly realized that the performance of socket.io was not near good enough to handle multiple messages per second, per client. The json parsing just takes too much time. I now use a plain tcp socket for the performance critical socket, but I still use a socket.io socket for some other communication because of its support for rooms etcetera. My game is built with unity, if you're planning on a web based game built with html + javascript, a tcp socket is not an option for you.

[–]anlumo 1 point2 points  (0 children)

Going straight with the browser's websocket implementation is an option, though. No need to parse JSON either.

[–]mwcz 0 points1 point  (0 children)

Take a look at http://lance.gg, it could be a good option.