コード例 #1
0
        void StartQosMatchmaking(string mmServiceURL, string multiplayFleetID, CancellationToken token = default)
        {
            if (string.IsNullOrEmpty(multiplayFleetID))
            {
                Debug.LogError("Qos Discovery Failed - Fleet ID was missing or invalid");
                return;
            }

            // Start with Qos Discovery
            OnStateChanged(MatchmakingState.QosDiscovery);
            m_QosDiscovery = new QosDiscoveryAsyncWrapper();

            m_QosDiscovery.Start(multiplayFleetID, 0, servers =>
            {
                if (token.IsCancellationRequested)
                {
                    Debug.Log("Qos Discovery Cancelled");
                    OnStateChanged(MatchmakingState.Idle);
                    return;
                }

                m_QosServers = servers;

                if (m_QosServers == null || m_QosServers.Length == 0)
                {
                    Debug.LogError($"Qos Discovery Failed - No servers found for {multiplayFleetID}");
                    OnStateChanged(MatchmakingState.Idle);
                    return;
                }

                // Move on to Qos Ping
                StartQosPing(mmServiceURL, multiplayFleetID, token);
            });
        }
コード例 #2
0
        IEnumerator DoQosAsync()
        {
            // Qos Discovery - Find servers to ping
            var qosDiscovery = new QosDiscoveryAsyncWrapper();

            yield return(qosDiscovery.StartEnumerator(m_FleetId));

            var servers = qosDiscovery.Servers;

            if (servers == null || servers.Length == 0)
            {
                Debug.LogWarning("Qos was requested, but no qos servers could be found.");
                yield break;
            }

            // Qos Pings - Ping servers for info
            var qosPinger = new QosPingAsyncWrapper(servers);

            yield return(qosPinger.StartEnumerator());

            m_QosResults = qosPinger.QosResults;

            if (m_QosResults == null || m_QosResults.Count == 0)
            {
                Debug.LogWarning("Qos was requested, but no valid qos results were returned.");
            }
            else
            {
                QosConnector.Instance.RegisterProvider(() => m_QosResults);
            }
        }