Specialized components
Matchmaking system
Open match integration
12 min
welcome to our exploration of ir engine's matchmaking system! in this chapter, we'll dive into how ir engine integrates with google's open match framework to provide a powerful and scalable matchmaking solution what is open match? open match is an open source matchmaking framework developed by google and unity it's designed to be flexible, scalable, and customizable, making it perfect for connecting players in multiplayer games and virtual experiences at its core, open match provides a ticket based system for tracking player matchmaking requests a component based architecture that separates concerns kubernetes native deployment for scalability customizable matching logic through user defined functions ir engine's open match integration ir engine integrates open match through the @ir engine/matchmaking package this package provides client side apis for creating and tracking match tickets server side services for managing the matchmaking process custom matchmaking functions for ir engine's specific needs a director component for assigning matches to instanceservers let's look at the structure of the matchmaking package packages/matchmaking/ ├── src/ │ ├── functions/ # client side matchmaking functions │ ├── match ticket schema ts # match ticket schema definition │ └── ├── open match custom pods/ # custom open match components │ ├── director/ # match director implementation │ │ └── main go # go implementation of the director │ └── matchfunction/ # matchmaking function implementation │ └── mmf/ # match function logic │ ├── matchfunction go │ └── server go └── package json how open match works in ir engine when a player wants to join a multiplayer experience in ir engine, the following sequence occurs the client creates a match ticket with player preferences the ticket is stored in open match's ticket pool the matchmaking function periodically processes tickets to form matches the director assigns matches to instanceservers players are notified of their match assignment players connect to the assigned instanceserver let's look at how a match ticket is created // simplified from packages/matchmaking/src/functions ts export const createticket = async (gamemode string) promise\<matchtickettype> => { // create a ticket in the database const ticket = await api instance service(matchticketpath) create({ gamemode }) return ticket } open match components in ir engine ir engine implements several custom open match components 1\ matchmaking function (mmf) the matchmaking function is implemented in go and deployed as a kubernetes pod it's responsible for querying the ticket pool for available tickets grouping tickets into potential matches based on game mode and other criteria calculating a score for each potential match submitting matches to the open match backend // simplified from packages/matchmaking/open match custom pods/matchfunction/mmf/matchfunction go func makematches(p pb matchprofile, pooltickets map\[string]\[] pb ticket) (\[] pb match, error) { // group tickets by game mode ticketgroups = groupticketsbygamemode(pooltickets) // create matches from ticket groups var matches \[] pb match for gamemode, tickets = range ticketgroups { // create matches with appropriate team sizes // // calculate match score matchscore = scorecalculator(matchtickets) // create the match matches = append(matches, \&pb match{ matchid fmt sprintf("profile %v time %v %v", p getname(), time now() format("2006 01 02t15 04 05 00"), count), matchprofile p getname(), matchfunction matchname, tickets matchtickets, // }) } return matches, nil } 2\ director the director is also implemented in go and deployed as a kubernetes pod it's responsible for fetching matches from the open match backend assigning matches to instanceservers notifying players of their match assignment // simplified from packages/matchmaking/open match custom pods/director/main go func assign(be pb backendserviceclient, p pb matchprofile, matches \[] pb match) error { for , match = range matches { // get ticket ids from the match var ticketids \[]string for , ticket = range match gettickets() { ticketids = append(ticketids, ticket getid()) } // generate a connection string (instanceserver id) conn = uuid new() string() // assign tickets to the connection req = \&pb assignticketsrequest{ assignments \[] pb assignmentgroup{ { ticketids ticketids, assignment \&pb assignment{ connection conn, // }, }, }, } // make the assignment if , err = be assigntickets(context background(), req); err != nil { return fmt errorf("assigntickets failed for match %v, got %w", match getmatchid(), err) } } return nil } deploying open match with ir engine ir engine provides scripts and helm charts for deploying open match on kubernetes \# from packages/matchmaking/readme md \# start minikube with ingress minikube start addons ingress \# install open match with helm helm install set frontend host=\<hostname> open match packages/ops/open match \# build and deploy the custom pods helm install f path/to/matchmaking yaml set director image tag=\<tag>,matchfunction image tag=\<tag> \<release> matchmaking /ops/etherealengine matchmaking integration with ir engine's server core the matchmaking system integrates with ir engine's server core through several services matchticketservice manages match tickets in the database matchticketassignmentservice handles match assignments matchuserservice associates users with match tickets matchinstanceservice manages match instances these services provide the bridge between ir engine's backend and the open match framework conclusion ir engine's integration with open match provides a powerful, scalable matchmaking solution that can handle a wide variety of matchmaking scenarios by leveraging open match's flexible architecture and kubernetes native deployment, ir engine can match players efficiently while maintaining full control over the matchmaking logic in the next chapter, we'll explore the lifecycle of a match ticket, from creation to assignment