Colyseus, an uncomplicated library for multiplayer games

A couple of weeks ago we released our latest game, Mini Pool. It has been a success and Colyseus.io has contributed a lot to achieving this. Our programmers had less stress dealing with server issues and could concentrate on developing game play.

 


We considered to code the server side directly with node and websockets. It isn’t an incredible amount of work but why reinvent the wheel? Colyseus is above all easy to understand and implement. It takes care of the rooms creation, matching and player’s disconnection handling. One of the strengths of this framework is how it manages the room state. Basically we create a custom data structure for the room state and every time those data are changed by the server all clients are informed and act correspondingly. This feature means less messages and less code in the server side.

 

For example the state object of the Room in the server side has a field called “currentTurn”. If the server logic change its value both clients are notified that the turn has changed without having to broadcast manually a message.

 

 

Due to performance reasons the physics engine is implemented in the client side. However the server is authoritative, each turn it validates balls positions and makes sure that both clients are synchronized and positions are consistent.

 

Another interesting feature of Colyseus is that is coded in TypeScript which is precisely the language we use in the client side.

Colyseus is open source, the project is well maintained and has a forum where usually all doubts are solved in matter of hours.