Diarkis MatchMaker - How To Add Searchable Items

We explain how to add searchable items using Diarkis MatchMaker and Room.

How To Add An Item To MatchMaker

You must “add” to MatchMaker in order to be searched and matched. We recommend adding items with short TTL and keep adding them until they are no longer needed. Add is relatively cheap, but Remove is expensive.

NOTE: Maximum TTL is 60 seconds. In order to have long-lasting items (longer than 60 seconds), you need to add the items repeatedly until you no longer need them.

NOTE: This can be written on HTTP, TCP, and/or UDP/RUDP

The example below shows how to add a room to MatchMaker:

// MatchMaker item property to be searched by
props := make(map[string]int)
props["level"] = 30
props["rank"] = 7

// Unique name of the match-making definition to add the room to
matchingName := "levelAndRank"

// roomMetadata will be retrieved as the search results.
data := make(map[string]interface{})
data["roomID"] = roomID
data["roomType"] = 2
data["roomName"] = "Room of level 30 and rank 7"

// TTL of the room in match-making. TTL is in seconds
ttl := int64(30)

// relayLimit is the number of server nodes to send the data to at a time:
// Greater the value, the faster and more CPU intense it is
relayLimit := 2

matching.Add(matchingName, roomID, props, roomMetadata, ttl, relayLimit)