Exemplo n.º 1
0
    IEnumerator DoTestNetwork(Globals.TestNetDelegate del)
    {
        float testNetTimeout = 1;         // second
        float connectingTime = 0;

        // [220.181.111.85] is www.baidu.com ip address
        UnityEngine.Ping ping = new UnityEngine.Ping("220.181.111.85");
        while (!ping.isDone && connectingTime < testNetTimeout)
        {
            connectingTime += Time.deltaTime;
            yield return(0);
        }

        Debug.Log(ping.ip);
        Debug.Log(ping.time);

        bool isSuccessed = ping.isDone;

        ping.DestroyPing();
        if (null != del)
        {
            del(isSuccessed);
        }

        yield return(0);
    }
Exemplo n.º 2
0
 public void TestNetwork(Globals.TestNetDelegate del)
 {
     StartCoroutine(DoTestNetwork(del));
 }