Quick Start

This script gets a player into a search and logs the result. It assumes you've installed the package and have a ticket endpoint.

using System;
using System.Net.Http;
using Pairiquium.Tickets;
using Pairiquium.Unity;
using UnityEngine;
 
public class MyMatchmaking : MonoBehaviour
{
    private static readonly HttpClient Http = new HttpClient();
 
    private MatchmakingBehaviour _matchmaking;
 
    void Start()
    {
        var tickets = new HttpTicketProvider(
            Http, new Uri("https://your-backend.example.com/matchmaking/ticket"));
 
        _matchmaking = gameObject.AddComponent<MatchmakingBehaviour>();
        _matchmaking.Initialize(tickets);
 
        _matchmaking.OnMatchFound.AddListener(metadata =>
            Debug.Log($"Matched! matchId={metadata.MatchId} team={metadata.Team}"));
 
        _matchmaking.OnError.AddListener((error, isTerminal) =>
            Debug.LogWarning($"{error.Code}: {error.Message} (terminal: {isTerminal})"));
 
        _ = _matchmaking.BeginSearchAsync("1v1");
    }
}

MatchmakingBehaviour is the Unity-facing entry point. It raises its events on Unity's main thread, so they are safe to use with UI and scene objects. Call Initialize once, before anything else.

Start, cancel, and close

await _matchmaking.BeginSearchAsync("1v1");                  // let Pairiquium pick the region
await _matchmaking.BeginSearchAsync("1v1", "us-east-1");     // lock to a region
await _matchmaking.CancelSearchAsync();                      // stop searching, keep the connection
await _matchmaking.CloseAsync();                             // close the connection
  • BeginSearchAsync gets a ticket, connects, and starts the search. The game mode is the ID you configured in the dashboard. The optional region is passed to your ticket endpoint as preferredRegion, and the SDK keeps using it for every reconnect during that search.
  • If the connection can't be made (for example your ticket endpoint is down), the SDK reports it through OnError and retries with backoff. You don't need to wrap the call in a retry loop.
  • Once you have a match, call CloseAsync(): the matchmaking connection has finished its job. See After a Match.

Initialize first

BeginSearchAsync, CancelSearchAsync, and CloseAsync throw if you haven't called Initialize.

Playing with friends? Connect first with ConnectAsync and form a party before searching. See Parties.

Next

The SDK reports what is happening through events. See Events & States.