Manage And Control MatchMaker Ticket Logic From The Server

MatchMaker Ticket allows the server to take full control of matchmakings performed by tickets.

The server can manage and control the logic of all matchmakings performed by tickets.

The advantage of having the server to manage and control matchmaking logics is when you change the matchmaking rules and logics, the client does not have to change at all.

Setup The Callback Create Ticket When The Client Issues A Ticket

This callback is responsible for creating all matchmaking tickets when the client issues a matchmaking ticket.

The callback is invoked every time the client issues a ticket. You may change values of the ticket based on the user (client) that issued the ticket.

Here you can control the content of the ticket.

// import github.com/Diarkis/diarkis/matching github.com/Diarkis/diarkis/user


// userData is the data representation of the client issued the ticket
matching.SetOnIssueTicket(func(userData *user.User) *matching.TicketParams {
 return &matching.TicketParams{

// Control which matchmaking profiles the issued ticket should use
ProfileIDs:     []string{"RankMatch", "RankMatch2"},

// Control the maximum number of clients to be matched
MaxMembers:     2,

// Controls how long the each search should wait before performing next search
SearchInterval: 100, // 100 milliseconds

// Controls how long should the issued ticket be valid in seconds
TicketDuration: 60,  // 1 minute

// Controls how many matched candidates should a search should retrieve
HowMany:        20,

// Controls if the issued ticket should use MatchMaker Tag
Tag: "",

// Controls the conditions of the matchmaking wait (conditions to be found by others)
AddProperties: map[string]int{"rank": userData.Get("UserRank")},

// Controls the conditions for matchmaking search
S SearchProperties: map[string][]int{ "rank": []int{ 1, 2, 3 } },
}
}

Add Custom Logic To Determine The Completion Of Matchmaking

When a ticket finds the number of matched clients that equals the MaxMembers value, MatchMaker will automatically decide that the matchmaking is complete and send the notifications to all the matched clients.

However, you may add your own custom logic to decide how and when a matchmaking should be considered "complete" without reaching MaxMembers.

matching.SetOnTicketMatch(func(userData *user.User, roomID string, memberIDs []string) bool {
// Add custom logic to decide matchmaking completion here
// userData represents the client that issued the ticket
// roomID represents the matchmaking room that all matched clients belong to
// memberIDs is the list of all matched clients' user IDs
return false
})

Setup The Callback To Create Notification Message

The completion of matchmaking notifications contain message data, you may manage and control what you send as the notification to the client by using the callback explained below.

matching.SetOnTicketComplete(func(roomID string, userData *user.User) []byte {
 // roomID represents the matchmaking room that all matched clients belong to
 // userData represents the client that issued the ticket
return []byte("Send some meaningful information here...")
}