Creation of a peer-to-peer network for online multiplayer game

I am creating a turn based multiplayer strategy game with javascript and html, I am at the point where I am creating multiplayer functionality. I looked at the options and due to the fact that there will be a maximum of 8 players at the same time, and this will be a twist, so only one player will manipulate the game at a time, I came to the conclusion that peer-to-peer would be a good solution. However, I cannot find articles that detail how to install something like this.

All the tutorials and articles I've found explain what a peer-to-peer network is, problems and possible solutions, but nothing detailed on how to set up peer-to-peer connections, etc. The articles / tutorials I found that go into the details revolve around a p2p client being downloaded to the user's computer. I don't want the user to download anything. I would like users to be able to customize the game on the site and use the connection information of the players who join the game so that it can be verified using the javascript that has been loaded in their browser. Maybe I don’t understand how a peer works? Is it possible?

I am looking for any articles, tutorials that can help me achieve this, or if someone can explain, I would not mind explaining .. or if I don’t understand how everything works and this is not possible, it would be good to know as well.

+3


source to share


1 answer


There are many options. Ultimately though, unless the computers are on the same network, you'll need a server in the middle to handle routing and inject new connections.



  • A NodeJS server that opens a web socket with each of the clients and can negotiate messages as well as pass data from the server to the client (which is what you need).
  • WebRTC is an api protocol available in latest browsers and sites like: http://www.rtcmulticonnection.org/ has many resources and libraries available to help you get started.
  • You can use any of a variety of messaging servers such as XMPP, STUN, ActiveMQ (my favorite), etc., and can follow typical pub / helper patterns when using websockets, rtc, etc.
0


source







All Articles