// Initialize a new matchmaking request and set UI state to Matchmaking In Progress
        // Precondition: MatchmakingServer is not null and contains a valid matchmaking URI
        void StartNewMatchmakingRequest()
        {
            // Abort existing matchmaker
            if (m_Matchmaker != null)
            {
                EndMatchmaking();
            }

            m_LastMatchmakingState = default(Matchmaker.MatchmakingState);

            MatchmakingServer = MatchmakingServer.Trim();

            m_Matchmaker = new Matchmaker(MatchmakingServer, OnMatchmakingSuccess, OnMatchmakingError);

            var matchId     = Guid.NewGuid().ToString();
            var playerProps = new MatchmakingUtilities.PlayerProperties {
                hats = 5
            };
            var groupProps = new MatchmakingUtilities.GroupProperties {
                mode = 0
            };
            var request = MatchmakingUtilities.CreateMatchmakingRequest(matchId, playerProps, groupProps);

            m_Matchmaker.RequestMatch(request);
            m_LastMatchmakingState = m_Matchmaker.State;
        }
        // Update the state machines
        void Update()
        {
            if (m_Matchmaker != null)
            {
                m_Matchmaker.Update();
                m_LastMatchmakingState = m_Matchmaker.State;
            }

            if (s_Headless)
            {
                UpdateForHeadless();
            }
            else
            {
                UpdateForGUI();
            }
        }
        void EndMatchmaking()
        {
            // Headless only supports 1 mm attempt, so if we end/abort, we're done
            m_HeadlessShouldMatchmake = false;

            // Clean up existing matchmaker
            if (m_Matchmaker != null)
            {
                m_LastMatchmakingState = m_Matchmaker.State;

                // See if we need to cancel an existing matchmaking request
                if (!m_Matchmaker.Done)
                {
                    // TODO: Add cancel functionality when matchmaking client library is updated with it
                }
            }

            m_Matchmaker = null;
        }