How To Use MatchMaker Ticket

MatchMaker Ticket allows the server to have the complete control over matchmaking logic. The client simply needs to issue a ticket and wait for the server to complete the matchmaking.

Using a ticket issued by MatchMaker, the client simply has to wait for the server to perform matchmaking and notify the matched clients.

The control of the matchmakings performed by tickets is handled by the server.

To learn how to manage the server-side of MatchMaker Ticket, please read here.

The upside of having the server to have the full control of matchmaking logics, the client does not require any change should the matchmaking specs and logics change.

Initialize MatchMaker Class and Setup Logger

#define REG_EVENT(__EVENT__, __LAMBDA__) this->eventUnsubscriptions.push_back(__EVENT__->Register(__LAMBDA__))

void DiarkisMatchMakerBase::SetupUdpMatchMaker(std::shared_ptr<IDiarkisUdp> udp_, std::shared_ptr<LoggerFactory> loggerFactory)
{
mm = shared_ptr<IDiarkisMatchMaker>(DiarkisCreateMatchMaker());
mm->SetupAsUdp(udp_));

   // Setup the logger
mm->SetLoggerFactory(loggerFactory, "-UDP");


// Setup the event listeners for tickets
   REG_EVENT(mm->GetTicketCompleteEvent(), [this](void*, const DiarkisMMHostEventArgs& e) { OnTicketComplete(e); });  
   REG_EVENT(mm->GetTicketCancelEvent(), [this](void*, const DiarkisMMHostEventArgs& e) { OnTicketCancel(e); }
}

How To Issue A New Ticket

The server will send a notification when a matchmaking ticket finishes finding matches or fails to find matches. Matched remote clients will also receive a notifications when matched with the client that issued the matchmaking ticket.

The notification event from the server when the ticket completes its operations will be captured by "GetTicketCompleteEvent".

mm->IssueTicket();

How To Cancel Issued Ticket

There may be a time when you want to cancel the matchmaking ticket you have issued.

Here is how.

Important: You may cancel tickets that are issued by yourself only.

mm->CancelTicket();