Offline Matchmaking #

Offline matchmaking is a way to find matches for users who are not currently connected to the server. This can be useful in many aspects, such as:

  • Asynchronous multiplayer games where players don’t need to be online at the same time, such as turn-based strategy games or puzzle games. Offline matchmaking can be used to pair players based on their skill level, game preferences, or other factors. Players can then take their turns at their own convenience.

  • Scheduling matches for specific times, where offline matchmaking can be used to find suitable opponents in advance. This can be particularly useful for competitive games with large player bases.

  • Match Suggestions can be used to suggest potential matches to players when they log in. This can help to engage players and encourage them to play more matches.

  • Player retention can be improved by providing players with suitable matches even when they’re not online. Players are more likely to return to a game if they know they have a match waiting for them.

Nakama supports offline matchmaking by enabling developers to query specified indices in the storage engine using the same query syntax as the Matchmaker. This way it is possible to lookup matches based on any player criteria from the collections they elect to index, even when the players are not online.

Configuration #

Offline matchmaking is implemented via the server framework. As part of your custom logic, whether written in TypeScript, Lua, or Go, you can configure your desired indices and the filters used for writing to them.

RegisterStorageIndex #

Server
1
2
3
4
5
6
7
name := "IndexName"
collection := "CollectionName"
key := "KeyName"
fields := []string{"field1", "field2", "field3"}
maxEntries := 1000

err := initializer.RegisterStorageIndex(name, collection, key, fields, maxEntries)
Server
1
2
3
4
5
6
7
local name = "IndexName"
local collection = "CollectionName"
local key = "KeyName"
local fields = {"field1", "field2", "field3"}
local maxEntries = 1000

local err = nk.register_storage_index(name, collection, key, fields, maxEntries)
Server
 1
 2
 3
 4
 5
 6
 7
 8
 9
10
11
12
const name = "IndexName";
const collection = "CollectionName";
const key = "KeyName";
const fields = ["field1", "field2", "field3"];
const maxEntries = 1000;

try {
    initializer.registerStorageIndex(name, collection, key, fields, maxEntries);
} (catch err) {
    // handle error
}

RegisterStorageIndexFilter #

It is possible to register a custom filtering function per index to be called for every eligible object.

See the storage indices documentation for more details.

Usage #

Unlike the Matchmaker, offline matchmaking is accomplished via the server framework, specifically the storageIndexList function.

Related Pages