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); }
static public int DestroyPing(IntPtr l) { try{ UnityEngine.Ping self = (UnityEngine.Ping)checkSelf(l); self.DestroyPing(); return(0); } catch (Exception e) { LuaDLL.luaL_error(l, e.ToString()); return(0); } }
private System.Collections.IEnumerator createPinger(string ip, float timeout) { #if !UNITY_WEBGL if (ip != myip) { UnityEngine.Ping ping = new UnityEngine.Ping(ip); float timer = 0; while (!ping.isDone && timer < timeout) { timer += Time.deltaTime; yield return(null); } if (ping.time != -1) { upCount++; string mac = null; #if UNITY_STANDALONE_WIN || UNITY_EDITOR_WIN mac = getMacByIp(ip); #elif UNITY_ANDROID mac = AndroidUSBUtils.CurrentInstance.GetMacAddressQ(ip); #endif string addit = "Unknown"; if (idents != null && mac != null) { string macLookup = getFirst3MacValues(mac.ToUpper()); if (hexToManufacturerHash.ContainsKey(macLookup)) { addit = hexToManufacturerHash[macLookup]; } if (addit.StartsWith("Nintendo", StringComparison.OrdinalIgnoreCase)) { addit = "<color=red>" + addit + "</color>"; } activeIP.Add(string.Format("IP: {0} Mfr: {1}", ip, addit)); } else { activeIP.Add(string.Format("IP: {0}", ip)); } } ping.DestroyPing(); } else { activeIP.Add(string.Format("IP: {0} (This device)", ip)); } pingCount++; percentageDone.UpdateValue(pingCount / 255f); #else yield return(null); #endif }
static public int DestroyPing(IntPtr l) { try { UnityEngine.Ping self = (UnityEngine.Ping)checkSelf(l); self.DestroyPing(); pushValue(l, true); return(1); } catch (Exception e) { return(error(l, e)); } }
static int DestroyPing(IntPtr L) { try { ToLua.CheckArgsCount(L, 1); UnityEngine.Ping obj = (UnityEngine.Ping)ToLua.CheckObject(L, 1, typeof(UnityEngine.Ping)); obj.DestroyPing(); return(0); } catch (Exception e) { return(LuaDLL.toluaL_exception(L, e)); } }
public void Update(float elapseSeconds, float realElapseSeconds) { if (m_Ping == null || Application.internetReachability != NetworkReachability.NotReachable) { if (Time.unscaledTime >= m_NextPingTime) { m_Ping = new UnityEngine.Ping(m_IPString); } } else if (Application.internetReachability == NetworkReachability.NotReachable) { m_PingValue = 0f; m_NextPingTime = Time.unscaledTime; m_Ping.DestroyPing(); m_Ping = null; } else if (m_Ping.isDone) { m_PingValue = m_Ping.time; m_NextPingTime = Time.unscaledTime + m_PingInterval; m_Ping.DestroyPing(); m_Ping = null; } }