PingSocket() public méthode

Affected by frame-rate of app, as this Coroutine checks the socket for a result once per frame.
public PingSocket ( Region, region ) : IEnumerator
region Region,
Résultat IEnumerator
Exemple #1
0
    internal IEnumerator PingAvailableRegionsCoroutine(bool connectToBest)
    {
        BestRegionCodeCurrently = CloudRegionCode.none;
        while (PhotonNetwork.networkingPeer.AvailableRegions == null)
        {
            if (PhotonNetwork.connectionStateDetailed != PeerState.ConnectingToNameServer && PhotonNetwork.connectionStateDetailed != PeerState.ConnectedToNameServer)
            {
                Debug.LogError("Call ConnectToNameServer to ping available regions.");
                yield break; // break if we don't connect to the nameserver at all
            }

            Debug.Log("Waiting for AvailableRegions. State: " + PhotonNetwork.connectionStateDetailed + " Server: " + PhotonNetwork.Server + " PhotonNetwork.networkingPeer.AvailableRegions " + (PhotonNetwork.networkingPeer.AvailableRegions != null));
            yield return(new WaitForSeconds(0.25f)); // wait until pinging finished (offline mode won't ping)
        }

        if (PhotonNetwork.networkingPeer.AvailableRegions == null || PhotonNetwork.networkingPeer.AvailableRegions.Count == 0)
        {
            Debug.LogError("No regions available. Are you sure your appid is valid and setup?");
            yield break; // break if we don't get regions at all
        }

        //#if !UNITY_EDITOR && (UNITY_ANDROID || UNITY_IPHONE)
        //#pragma warning disable 0162    // the library variant defines if we should use PUN's SocketUdp variant (at all)
        //if (PhotonPeer.NoSocket)
        //{
        //    if (PhotonNetwork.logLevel >= PhotonLogLevel.Informational)
        //    {
        //        Debug.Log("PUN disconnects to re-use native sockets for pining servers and to find the best.");
        //    }
        //    PhotonNetwork.Disconnect();
        //}
        //#pragma warning restore 0162
        //#endif

        PhotonPingManager pingManager = new PhotonPingManager();

        foreach (Region region in PhotonNetwork.networkingPeer.AvailableRegions)
        {
            SP.StartCoroutine(pingManager.PingSocket(region));
        }

        while (!pingManager.Done)
        {
            yield return(new WaitForSeconds(0.1f)); // wait until pinging finished (offline mode won't ping)
        }


        Region best = pingManager.BestRegion;

        PhotonHandler.BestRegionCodeCurrently     = best.Code;
        PhotonHandler.BestRegionCodeInPreferences = best.Code;

        Debug.Log("Found best region: " + best.Code + " ping: " + best.Ping + ". Calling ConnectToRegionMaster() is: " + connectToBest);


        if (connectToBest)
        {
            PhotonNetwork.networkingPeer.ConnectToRegionMaster(best.Code);
        }
    }
 // Token: 0x0600B24D RID: 45645 RVA: 0x0041687C File Offset: 0x00414A7C
 internal IEnumerator LONCMFKCCJD(bool BHOGFDENPBF)
 {
     while (PhotonNetwork.JNJJAMNLOHA.AvailableRegions == null)
     {
         if (PhotonNetwork.connectionStateDetailed != ClientState.ConnectingToNameServer && PhotonNetwork.connectionStateDetailed != ClientState.ConnectedToNameServer)
         {
             UnityEngine.Debug.LogError("Call ConnectToNameServer to ping available regions.");
             yield break;
         }
         UnityEngine.Debug.Log(string.Concat(new object[]
         {
             "Waiting for AvailableRegions. State: ",
             PhotonNetwork.connectionStateDetailed,
             " Server: ",
             PhotonNetwork.Server,
             " PhotonNetwork.networkingPeer.AvailableRegions ",
             PhotonNetwork.JNJJAMNLOHA.AvailableRegions != null
         }));
         yield return(new WaitForSeconds(0.25f));
     }
     if (PhotonNetwork.JNJJAMNLOHA.AvailableRegions == null || PhotonNetwork.JNJJAMNLOHA.AvailableRegions.Count == 0)
     {
         UnityEngine.Debug.LogError("No regions available. Are you sure your appid is valid and setup?");
         yield break;
     }
     photonPingManager = new PhotonPingManager();
     enumerator        = PhotonNetwork.JNJJAMNLOHA.AvailableRegions.GetEnumerator();
     try
     {
         while (enumerator.MoveNext())
         {
             Region lpcnahjgafk = enumerator.Current;
             PhotonHandler.SP.StartCoroutine(photonPingManager.PingSocket(lpcnahjgafk));
         }
     }
     finally
     {
         ((IDisposable)enumerator).Dispose();
     }
     while (!photonPingManager.Done)
     {
         yield return(new WaitForSeconds(0.1f));
     }
     bestRegion = photonPingManager.BestRegion;
     PhotonHandler.IFAEAEOAJDL = bestRegion.Code;
     UnityEngine.Debug.Log(string.Concat(new object[]
     {
         "Found best region: '",
         bestRegion.Code,
         "' ping: ",
         bestRegion.Ping,
         ". Calling ConnectToRegionMaster() is: ",
         BHOGFDENPBF
     }));
     if (BHOGFDENPBF)
     {
         PhotonNetwork.JNJJAMNLOHA.ConnectToRegionMaster(bestRegion.Code);
     }
     yield break;
 }
Exemple #3
0
    // Token: 0x06003D00 RID: 15616 RVA: 0x001343E4 File Offset: 0x001327E4
    internal IEnumerator PingAvailableRegionsCoroutine(bool connectToBest)
    {
        while (PhotonNetwork.networkingPeer.AvailableRegions == null)
        {
            if (PhotonNetwork.connectionStateDetailed != ClientState.ConnectingToNameServer && PhotonNetwork.connectionStateDetailed != ClientState.ConnectedToNameServer)
            {
                UnityEngine.Debug.LogError("Call ConnectToNameServer to ping available regions.");
                yield break;
            }
            UnityEngine.Debug.Log(string.Concat(new object[]
            {
                "Waiting for AvailableRegions. State: ",
                PhotonNetwork.connectionStateDetailed,
                " Server: ",
                PhotonNetwork.Server,
                " PhotonNetwork.networkingPeer.AvailableRegions ",
                PhotonNetwork.networkingPeer.AvailableRegions != null
            }));
            yield return(new WaitForSeconds(0.25f));
        }
        if (PhotonNetwork.networkingPeer.AvailableRegions == null || PhotonNetwork.networkingPeer.AvailableRegions.Count == 0)
        {
            UnityEngine.Debug.LogError("No regions available. Are you sure your appid is valid and setup?");
            yield break;
        }
        PhotonPingManager pingManager = new PhotonPingManager();

        foreach (Region region in PhotonNetwork.networkingPeer.AvailableRegions)
        {
            PhotonHandler.SP.StartCoroutine(pingManager.PingSocket(region));
        }
        while (!pingManager.Done)
        {
            yield return(new WaitForSeconds(0.1f));
        }
        Region best = pingManager.BestRegion;

        PhotonHandler.BestRegionCodeInPreferences = best.Code;
        UnityEngine.Debug.Log(string.Concat(new object[]
        {
            "Found best region: '",
            best.Code,
            "' ping: ",
            best.Ping,
            ". Calling ConnectToRegionMaster() is: ",
            connectToBest
        }));
        if (connectToBest)
        {
            PhotonNetwork.networkingPeer.ConnectToRegionMaster(best.Code);
        }
        yield break;
    }
    internal IEnumerator PingAvailableRegionsCoroutine(bool connectToBest)
    {
        BestRegionCodeCurrently = CloudRegionCode.none;
        while (PhotonNetwork.networkingPeer.AvailableRegions == null)
        {
            if (PhotonNetwork.connectionStateDetailed != PeerState.ConnectingToNameServer && PhotonNetwork.connectionStateDetailed != PeerState.ConnectedToNameServer)
            {
                Debug.LogError("Call ConnectToNameServer to ping available regions.");
                yield break; // break if we don't connect to the nameserver at all
            }

            Debug.Log("Waiting for AvailableRegions. State: " + PhotonNetwork.connectionStateDetailed + " Server: " + PhotonNetwork.Server + " PhotonNetwork.networkingPeer.AvailableRegions " + (PhotonNetwork.networkingPeer.AvailableRegions != null));
            yield return(new WaitForSeconds(0.25f)); // wait until pinging finished (offline mode won't ping)
        }

        if (PhotonNetwork.networkingPeer.AvailableRegions == null || PhotonNetwork.networkingPeer.AvailableRegions.Count == 0)
        {
            Debug.LogError("No regions available. Are you sure your appid is valid and setup?");
            yield break; // break if we don't get regions at all
        }

        PhotonPingManager pingManager = new PhotonPingManager();

        foreach (Region region in PhotonNetwork.networkingPeer.AvailableRegions)
        {
            SP.StartCoroutine(pingManager.PingSocket(region));
        }

        while (!pingManager.Done)
        {
            yield return(new WaitForSeconds(0.1f)); // wait until pinging finished (offline mode won't ping)
        }


        Region best = pingManager.BestRegion;

        PhotonHandler.BestRegionCodeCurrently     = best.Code;
        PhotonHandler.BestRegionCodeInPreferences = best.Code;

        Debug.Log("Found best region: " + best.Code + " ping: " + best.Ping + ". Calling ConnectToRegionMaster() is: " + connectToBest);


        if (connectToBest)
        {
            PhotonNetwork.networkingPeer.ConnectToRegionMaster(best.Code);
        }
    }
Exemple #5
0
 internal IEnumerator PingAvailableRegionsCoroutine(bool connectToBest)
 {
     PhotonHandler.BestRegionCodeCurrently = CloudRegionCode.none;
     while (PhotonNetwork.networkingPeer.AvailableRegions == null)
     {
         if (PhotonNetwork.connectionStateDetailed != PeerStates.ConnectingToNameServer && PhotonNetwork.connectionStateDetailed != PeerStates.ConnectedToNameServer)
         {
             UnityEngine.Debug.LogError("Call ConnectToNameServer to ping available regions.");
             yield break;
         }
         UnityEngine.Debug.Log("Waiting for AvailableRegions. State: " + PhotonNetwork.connectionStateDetailed + " Server: " + PhotonNetwork.Server + " PhotonNetwork.networkingPeer.AvailableRegions " + (PhotonNetwork.networkingPeer.AvailableRegions != null));
         yield return((object)new WaitForSeconds(0.25f));
     }
     if (PhotonNetwork.networkingPeer.AvailableRegions == null || PhotonNetwork.networkingPeer.AvailableRegions.Count == 0)
     {
         UnityEngine.Debug.LogError("No regions available. Are you sure your appid is valid and setup?");
     }
     else
     {
         PhotonPingManager         pingManager = new PhotonPingManager();
         List <Region> .Enumerator enumerator  = PhotonNetwork.networkingPeer.AvailableRegions.GetEnumerator();
         try
         {
             while (enumerator.MoveNext())
             {
                 Region region = enumerator.Current;
                 PhotonHandler.SP.StartCoroutine(pingManager.PingSocket(region));
             }
         }
         finally
         {
             ((IDisposable)enumerator).Dispose();
         }
         while (!pingManager.Done)
         {
             yield return((object)new WaitForSeconds(0.1f));
         }
         Region best = pingManager.BestRegion;
         PhotonHandler.BestRegionCodeCurrently     = best.Code;
         PhotonHandler.BestRegionCodeInPreferences = best.Code;
         UnityEngine.Debug.Log("Found best region: " + best.Code + " ping: " + best.Ping + ". Calling ConnectToRegionMaster() is: " + connectToBest);
         if (connectToBest)
         {
             PhotonNetwork.networkingPeer.ConnectToRegionMaster(best.Code);
         }
     }
 }
Exemple #6
0
    internal IEnumerator PingAvailableRegionsCoroutine(bool connectToBest)
    {
        BestRegionCodeCurrently = CloudRegionCode.none;
        while (PhotonNetwork.networkingPeer.AvailableRegions == null)
        {
            if (PhotonNetwork.connectionStateDetailed != PeerState.ConnectingToNameServer && PhotonNetwork.connectionStateDetailed != PeerState.ConnectedToNameServer)
            {
                Debug.LogError("Call ConnectToNameServer to ping available regions.");
                yield break; // break if we don't connect to the nameserver at all
            }

            Debug.Log("Waiting for AvailableRegions. State: " + PhotonNetwork.connectionStateDetailed + " Server: " + PhotonNetwork.Server + " PhotonNetwork.networkingPeer.AvailableRegions " + (PhotonNetwork.networkingPeer.AvailableRegions != null));
            yield return new WaitForSeconds(0.25f); // wait until pinging finished (offline mode won't ping)
        }

        if (PhotonNetwork.networkingPeer.AvailableRegions == null || PhotonNetwork.networkingPeer.AvailableRegions.Count == 0)
        {
            Debug.LogError("No regions available. Are you sure your appid is valid and setup?");
            yield break; // break if we don't get regions at all
        }

        //#if !UNITY_EDITOR && (UNITY_ANDROID || UNITY_IPHONE)
        //#pragma warning disable 0162    // the library variant defines if we should use PUN's SocketUdp variant (at all)
        //if (PhotonPeer.NoSocket)
        //{
        //    if (PhotonNetwork.logLevel >= PhotonLogLevel.Informational)
        //    {
        //        Debug.Log("PUN disconnects to re-use native sockets for pining servers and to find the best.");
        //    }
        //    PhotonNetwork.Disconnect();
        //}
        //#pragma warning restore 0162
        //#endif

        PhotonPingManager pingManager = new PhotonPingManager();
        foreach (Region region in PhotonNetwork.networkingPeer.AvailableRegions)
        {
            SP.StartCoroutine(pingManager.PingSocket(region));
        }

        while (!pingManager.Done)
        {
            yield return new WaitForSeconds(0.1f); // wait until pinging finished (offline mode won't ping)
        }


        Region best = pingManager.BestRegion;
        PhotonHandler.BestRegionCodeCurrently = best.Code;
        PhotonHandler.BestRegionCodeInPreferences = best.Code;

        Debug.Log("Found best region: " + best.Code + " ping: " + best.Ping + ". Calling ConnectToRegionMaster() is: " + connectToBest);


        if (connectToBest)
        {
            PhotonNetwork.networkingPeer.ConnectToRegionMaster(best.Code);
        }
    }
Exemple #7
0
    internal IEnumerator PingAvailableRegionsCoroutine(bool connectToBest)
    {
        BestRegionCodeCurrently = CloudRegionCode.none;
        while (PhotonNetwork.networkingPeer.AvailableRegions == null)
        {
            if (PhotonNetwork.connectionStateDetailed != ClientState.ConnectingToNameServer && PhotonNetwork.connectionStateDetailed != ClientState.ConnectedToNameServer)
            {
                Debug.LogError("Call ConnectToNameServer to ping available regions.");
                yield break; // break if we don't connect to the nameserver at all
            }

            Debug.Log("Waiting for AvailableRegions. State: " + PhotonNetwork.connectionStateDetailed + " Server: " + PhotonNetwork.Server + " PhotonNetwork.networkingPeer.AvailableRegions " + (PhotonNetwork.networkingPeer.AvailableRegions != null));
            yield return new WaitForSeconds(0.25f); // wait until pinging finished (offline mode won't ping)
        }

        if (PhotonNetwork.networkingPeer.AvailableRegions == null || PhotonNetwork.networkingPeer.AvailableRegions.Count == 0)
        {
            Debug.LogError("No regions available. Are you sure your appid is valid and setup?");
            yield break; // break if we don't get regions at all
        }

        PhotonPingManager pingManager = new PhotonPingManager();
        foreach (Region region in PhotonNetwork.networkingPeer.AvailableRegions)
        {
            SP.StartCoroutine(pingManager.PingSocket(region));
        }

        while (!pingManager.Done)
        {
            yield return new WaitForSeconds(0.1f); // wait until pinging finished (offline mode won't ping)
        }


        Region best = pingManager.BestRegion;
        PhotonHandler.BestRegionCodeCurrently = best.Code;
        PhotonHandler.BestRegionCodeInPreferences = best.Code;

        Debug.Log("Found best region: " + best.Code + " ping: " + best.Ping + ". Calling ConnectToRegionMaster() is: " + connectToBest);


        if (connectToBest)
        {
            PhotonNetwork.networkingPeer.ConnectToRegionMaster(best.Code);
        }
    }
Exemple #8
0
    // Token: 0x06000413 RID: 1043 RVA: 0x0001A321 File Offset: 0x00018521
    internal IEnumerator PingAvailableRegionsCoroutine(bool connectToBest)
    {
        while (PhotonNetwork.networkingPeer.AvailableRegions == null)
        {
            if (PhotonNetwork.connectionStateDetailed != ClientState.ConnectingToNameServer && PhotonNetwork.connectionStateDetailed != ClientState.ConnectedToNameServer)
            {
                Debug.LogError("Call ConnectToNameServer to ping available regions.");
                yield break;
            }
            Debug.Log(string.Concat(new object[]
            {
                "Waiting for AvailableRegions. State: ",
                PhotonNetwork.connectionStateDetailed,
                " Server: ",
                PhotonNetwork.Server,
                " PhotonNetwork.networkingPeer.AvailableRegions ",
                (PhotonNetwork.networkingPeer.AvailableRegions != null).ToString()
            }));
            yield return(new WaitForSeconds(0.25f));
        }
        if (PhotonNetwork.networkingPeer.AvailableRegions == null || PhotonNetwork.networkingPeer.AvailableRegions.Count == 0)
        {
            Debug.LogError("No regions available. Are you sure your appid is valid and setup?");
            yield break;
        }
        PhotonPingManager pingManager = new PhotonPingManager();

        using (List <Region> .Enumerator enumerator = PhotonNetwork.networkingPeer.AvailableRegions.GetEnumerator())
        {
            while (enumerator.MoveNext())
            {
                Region region = enumerator.Current;
                PhotonHandler.SP.StartCoroutine(pingManager.PingSocket(region));
            }
            goto IL_16E;
        }
IL_14E:
        yield return(new WaitForSeconds(0.1f));

IL_16E:
        if (pingManager.Done)
        {
            Region bestRegion = pingManager.BestRegion;
            PhotonHandler.BestRegionCodeInPreferences = bestRegion.Code;
            Debug.Log(string.Concat(new object[]
            {
                "Found best region: '",
                bestRegion.Code,
                "' ping: ",
                bestRegion.Ping,
                ". Calling ConnectToRegionMaster() is: ",
                connectToBest.ToString()
            }));
            if (connectToBest)
            {
                PhotonNetwork.networkingPeer.ConnectToRegionMaster(bestRegion.Code, null);
            }
            yield break;
        }
        goto IL_14E;
    }