As the title says, I am having trouble getting people in a pool matched together. They just show up as separate tickets but the match requirements (query, min/max players) never get fulfilled.
Frontend code
const ticket: MatchmakerTicket = await socket.addMatchmaker("*", 2, 2);
console.log(ticket);
socket.onmatchmakermatched = (matched) => {
console.info("Received MatchmakerMatched message: ", matched);
console.info("Matched opponents: ", matched.users);
};
Backend code
export const matchmakerMatched = (
_context: nkruntime.Context,
logger: nkruntime.Logger,
nk: nkruntime.Nakama,
matches: nkruntime.MatchmakerResult[]
): string => {
logger.info("Match is Made");
matches.forEach(function (match) {
logger.info("Matched user '%s' named '%s'", match.presence.userId, match.presence.username);
Object.keys(match.properties).forEach(function (key) {
logger.info("Matched on '%s' value '%v'", key, match.properties[key]);
});
});
try {
const matchId = nk.matchCreate("standard", { invited: matches });
logger.debug(matchId);
return matchId;
} catch (error) {
throw logError(error, logger);
}
};
Init
initializer.registerMatchmakerMatched(matchmakerMatched);
Logs of 3 clients trying to get matched. The ticket gets shown in console.log()
as per the frontend code
Nothing is happening after this.
matchmaker.interval_sec
is set to 15 but even after waiting that long it stays quiet.
So on both the frontend (socket) as the backend (hook) the matchmaking doesn’t get triggered. I also tried them separately but without success.
Any clue? Thanks in advance