Sometimes you find something cool by accident.
This morning I stumbled across an interesting open source multiplayer server for Node JS called Colyseus. And I say stumbled because I wasn’t looking for something like this at all. I was researching a different problem entirely and it caught my eye.
Online multiplayer is a problem I have looked into before and this looks like a nice prepackaged solution.
How It Works
Colyseus is built on the idea that multiplayer games need an authoritative server.
All a game client should do, for a multiplayer game, is report the player input to the server and render the game state provided from the server back to the player. This can be a bit tricky over the internet with latency. Players can get frustrated because their input does not match what they expect from the games reaction.
Colyseus uses websockets and presents a set of lifecycle methods to plug your logic in and get started. It connects players to “rooms” that are game instances in memory. The players then interact with the room until the game is over at which point you can throw away the game state or store it in a database for later.
I will definitely be checking this out for some of my upcoming projects.
Learn More
You can learn more about this project by reading it’s documentation and checking out the source code.