This is an example on how to achieve Ranked Matchmaking within Colyseus.
This may be included as part of the core in the future. Feedback and more use-cases are welcome to ensure the most common ones are covered by this implementation.
- User joins
RankedLobbyRoom
with hisrank
number (trophies, mmr, etc.) - A compatible group is evaluated for each client at every 2 seconds.
- Once a compatible group is found, a room is created for them, with their seats reserved
- The clients then connect to the actual room, and disconnect from the lobby.
The gameServer
must define both the intermediary room and the actual game
room:
// register your room handlers
gameServer.define('ranked', RankedLobbyRoom);
gameServer.define('game', GameRoom);
The RankedLobbyRoom
has a few variables you can change to control how it works.
number of players on each match
Name of the room to create
After this time, create a match with a bot
after this time, try to fit this client with a not-so-compatible group
If allowUnmatchedGroups
is true, players inside an unmatched group (that did not reached numClientsToMatch
, and maxWaitingTime
has been reached) will be matched together. Your room should fill the remaining spots with "bots" on this case.
Evaluate groups for each client at interval
- There must be a way to prevent
"game"
rooms from being created directly, without passing through the"ranked"
process. - There is a low possibility that not all matched clients are going to connect
to the matched group due to their connectivity status, leaving some spots
empty - you can ensure bots will take their place after some time the
"game"
room has been created.
MIT