Exemplo n.º 1
0
 /// <summary>
 /// Initializes a new instance of the <see cref="Reachability.Reachability"/> class.
 /// </summary>
 /// <param name='reachability'>
 /// NetworkReachability instance to use
 /// </param>
 /// <param name='hasWWAN'>
 /// Platform has a WWAN interface
 /// </param>
 protected Reachability(NetworkReachability reachability, bool hasWWAN)
 {
     NetworkReachability = reachability;
     HasWWAN = hasWWAN;
     AllowWWAN = true;
     NetworkReachability.SetNotification(OnReachabilityNotification);
     NetworkReachability.Schedule(CFRunLoop.Current, CFRunLoop.ModeDefault);
 }
Exemplo n.º 2
0
 public static ENetworkDataType ConvertDataType(NetworkReachability type)
 {
     //return ENetworkDataType.MobileData;
     return type == NetworkReachability.NotReachable ?
         ENetworkDataType.None :
         type == NetworkReachability.ReachableViaCarrierDataNetwork ?
         ENetworkDataType.MobileData :
         ENetworkDataType.Cable;
 }
Exemplo n.º 3
0
        static NetworkInformation()
        {
#if __ANDROID__
            _manager = ConnectivityManager.FromContext(Plugin.CurrentActivity.CrossCurrentActivity.Current.Activity);
            //_manager = ConnectivityManager.FromContext(InTheHand.Platform.Android.ContextManager.Context);
#elif __IOS__ || __TVOS__
            _reachability = new NetworkReachability("0.0.0.0");
#endif
        }
Exemplo n.º 4
0
		static bool IsNetworkAvailable(out NetworkReachabilityFlags flags)
		{
			if (defaultRouteReachability == null) {
				defaultRouteReachability = new NetworkReachability(new IPAddress(0));
				defaultRouteReachability.SetNotification(OnChange);
				defaultRouteReachability.Schedule(CFRunLoop.Current, CFRunLoop.ModeDefault);
			}
			return defaultRouteReachability.TryGetFlags(out flags) && IsReachableWithoutRequiringConnection(flags);
		}
Exemplo n.º 5
0
		public static bool IsAdHocWiFiNetworkAvailable (out NetworkReachabilityFlags flags)
		{
			if (adHocWiFiNetworkReachability == null) {
				adHocWiFiNetworkReachability = new NetworkReachability(new IPAddress(new byte [] { 169, 254, 0, 0 }));
				adHocWiFiNetworkReachability.SetNotification(OnChange);
				adHocWiFiNetworkReachability.Schedule(CFRunLoop.Current, CFRunLoop.ModeDefault);
			}

			return adHocWiFiNetworkReachability.TryGetFlags(out flags) && IsReachableWithoutRequiringConnection(flags);
		}
Exemplo n.º 6
0
		// Is the host reachable with the current network configuration
		public static bool IsHostReachable(string host)
		{
			if (string.IsNullOrEmpty(host))
				return false;

			using (var r = new NetworkReachability(host)) {
				NetworkReachabilityFlags flags;

				if (r.TryGetFlags(out flags))
					return IsReachableWithoutRequiringConnection(flags);
			}
			return false;
		}
Exemplo n.º 7
0
    //
    // Returns true if it is possible to reach the AdHoc WiFi network
    // and optionally provides extra network reachability flags as the
    // out parameter
    //
    public static bool IsAdHocWiFiNetworkAvailable(out NetworkReachabilityFlags flags)
    {
        if (_adHocWiFiNetworkReachability == null) {
            _adHocWiFiNetworkReachability = new NetworkReachability (new IPAddress (new byte[] { 169, 254, 0, 0 }));
            _adHocWiFiNetworkReachability.SetCallback (OnChange);
            _adHocWiFiNetworkReachability.Schedule (CFRunLoop.Current, CFRunLoop.ModeDefault);
        }

        if (!_adHocWiFiNetworkReachability.TryGetFlags (out flags))
            return false;

        return IsReachableWithoutRequiringConnection (flags);
    }
Exemplo n.º 8
0
		// Is the host reachable with the current network configuration
		public static bool IsHostReachable (string host)
		{
			if (host == null || host.Length == 0)
				return false;
	
			using (var r = new NetworkReachability (host)){
				NetworkReachabilityFlags flags;
	
				if (r.TryGetFlags (out flags)){
					return IsReachableWithoutRequiringConnection (flags);
				}
			}
			return false;
		}
		void InitializeReachability ()
		{
			networkReachability = new NetworkReachability (IPAddress.Any);
			networkReachability.SetNotification (flags => UpdateReachability (flags, NetworkIcon, NetworkStatusTextField));
			networkReachability.Schedule ();

			NetworkReachabilityFlags networkReachabilityFlags;
			networkReachability.TryGetFlags (out networkReachabilityFlags);
			UpdateReachability (networkReachabilityFlags, NetworkIcon, NetworkStatusTextField);

			CreateHostReachability ();

			HostTextField.Changed += (sender, e) => CreateHostReachability ();
		}
Exemplo n.º 10
0
        public static bool IsAdHocWiFiNetworkAvailable(out NetworkReachabilityFlags flags)
        {
            if (adHocWiFiNetworkReachability == null)
            {
                adHocWiFiNetworkReachability = new NetworkReachability(new IPAddress(new byte[] {169, 254, 0, 0}));
#warning Need to look at SetNotification instead - ios6 change
                adHocWiFiNetworkReachability.SetNotification(OnChange);
                adHocWiFiNetworkReachability.Schedule(CFRunLoop.Current, CFRunLoop.ModeDefault);
            }

            if (!adHocWiFiNetworkReachability.TryGetFlags(out flags))
                return false;

            return IsReachableWithoutRequiringConnection(flags);
        }
Exemplo n.º 11
0
    public override bool FinishedLaunching(UIApplication app, NSDictionary options)
    {
        imageCarrier = UIImage.FromFile ("WWAN5.png");
        imageWiFi = UIImage.FromFile ("Airport.png");
        imageStop = UIImage.FromFile ("stop-32.png");

        nr = new NetworkReachability ("www.apple.com");
        nr.SetCallback (ReachabilityChanged);
        nr.Schedule (CFRunLoop.Current, CFRunLoop.ModeDefault);

        AddTable ();
        //UpdateStatus ();
        //UpdateCarrierWarning ();

        window.MakeKeyAndVisible ();

        return true;
    }
Exemplo n.º 12
0
		/// <summary>
		/// Checks if host is reachable
		/// </summary>
		/// <param name="host"></param>
		/// <param name="port"></param>
		/// <returns></returns>
		public static bool IsHostReachable (string host, int port)
		{
			if (string.IsNullOrWhiteSpace (host))
				return false;

			IPAddress address;
			if (!IPAddress.TryParse (host + ":" + port, out address)) {
				Debug.WriteLine (host + ":" + port + " is not valid");
				return false;
			}
			using (var r = new NetworkReachability (host)) {

				NetworkReachabilityFlags flags;

				if (r.TryGetFlags (out flags)) {
					return IsReachableWithoutRequiringConnection (flags);
				}
			}
			return false;
		}
		void CreateHostReachability ()
		{
			if (hostReachability != null) {
				hostReachability.Unschedule ();
				hostReachability.Dispose ();
			}

			if (String.IsNullOrEmpty (HostTextField.StringValue)) {
				HostIcon.Image = NSImage.ImageNamed ("disconnected");
				HostStatusTextField.StringValue = "Enter a host name or IP address";
				return;
			}

			hostReachability = new NetworkReachability (HostTextField.StringValue);
			hostReachability.SetNotification (flags => UpdateReachability (flags, HostIcon, HostStatusTextField));
			hostReachability.Schedule ();

			NetworkReachabilityFlags networkReachabilityFlags;
			networkReachability.TryGetFlags (out networkReachabilityFlags);
			UpdateReachability (networkReachabilityFlags, NetworkIcon, NetworkStatusTextField);
		}
		public void CreateConnectivityWatchDog (Action<bool> connectivityChanged)
		{
			this.connectivityChanged = connectivityChanged;

			if (remoteHostReachability == null)
			{
				if (remoteHostReachability != null)
				{
					remoteHostReachability.Unschedule(CFRunLoop.Current, CFRunLoop.ModeDefault);
				}

				// Create new instance if host address changed.
				remoteHostReachability = new NetworkReachability(new System.Net.IPAddress(0));
				remoteHostReachability.SetNotification(HandleReachabilityChanged);
				remoteHostReachability.Schedule(CFRunLoop.Current, CFRunLoop.ModeDefault);
			}

			// Trigger callback.
			if (this.connectivityChanged != null)
			{
				this.connectivityChanged (true);
			}
		}
Exemplo n.º 15
0
        internal static NetworkStatus RemoteHostStatus()
        {
            using (var remoteHostReachability = new NetworkReachability(HostName))
            {
                var reachable = remoteHostReachability.TryGetFlags(out var flags);

                if (!reachable)
                {
                    return(NetworkStatus.NotReachable);
                }

                if (!IsReachableWithoutRequiringConnection(flags))
                {
                    return(NetworkStatus.NotReachable);
                }

                if ((flags & NetworkReachabilityFlags.IsWWAN) != 0)
                {
                    return(NetworkStatus.ReachableViaCarrierDataNetwork);
                }

                return(NetworkStatus.ReachableViaWiFiNetwork);
            }
        }
Exemplo n.º 16
0
        void CreateHostReachability()
        {
            if (hostReachability != null)
            {
                hostReachability.Unschedule();
                hostReachability.Dispose();
            }

            if (String.IsNullOrEmpty(HostTextField.StringValue))
            {
                HostIcon.Image = NSImage.ImageNamed("disconnected");
                HostStatusTextField.StringValue = "Enter a host name or IP address";
                return;
            }

            hostReachability = new NetworkReachability(HostTextField.StringValue);
            hostReachability.SetNotification(flags => UpdateReachability(flags, HostIcon, HostStatusTextField));
            hostReachability.Schedule();

            NetworkReachabilityFlags networkReachabilityFlags;

            networkReachability.TryGetFlags(out networkReachabilityFlags);
            UpdateReachability(networkReachabilityFlags, NetworkIcon, NetworkStatusTextField);
        }
Exemplo n.º 17
0
    public static NetworkStatus RemoteHostStatus()
    {
        NetworkReachabilityFlags flags;
        bool reachable;

        if (remoteHostReachability == null)
        {
            remoteHostReachability = new NetworkReachability(HostName);

            reachable = remoteHostReachability.TryGetFlags(out flags);

            remoteHostReachability.SetCallback(OnChange);
            remoteHostReachability.Schedule(CFRunLoop.Current, CFRunLoop.ModeDefault);
        }
        else
        {
            reachable = remoteHostReachability.TryGetFlags(out flags);
        }

        if (!reachable)
        {
            return(NetworkStatus.NotReachable);
        }

        if (!IsReachableWithoutRequiringConnection(flags))
        {
            return(NetworkStatus.NotReachable);
        }

        if ((flags & NetworkReachabilityFlags.IsWWAN) != 0)
        {
            return(NetworkStatus.ReachableViaCarrierDataNetwork);
        }

        return(NetworkStatus.ReachableViaWiFiNetwork);
    }
Exemplo n.º 18
0
        /// <summary>
        /// 
        /// </summary>
        /// <param name="host">
        /// A <see cref="System.String"/>
        /// </param>
        /// <returns>
        /// A <see cref="NetworkType"/>
        /// </returns>
        private static NetworkType RemoteHostStatus(string host)
        {
            bool reachable = IsHostReachable(host);;

            if (!reachable)
                return NetworkType.Unknown;

            using (var r = new NetworkReachability (host)){
                NetworkReachabilityFlags flags;

                if (r.TryGetFlags (out flags)){
                    if ((flags & NetworkReachabilityFlags.IsWWAN) != 0)
                        //return NetworkType.Carrier_GSM;  // TODO get which type of carrier is being used.
                        return NetworkType.Carrier_3G; // HARDCODED.
                }
            }

            return NetworkType.Wifi;
        }
Exemplo n.º 19
0
        /// <summary>
        /// Is the host reachable with the current network configuration
        /// </summary>
        /// <param name="host">
        /// A <see cref="System.String"/>
        /// </param>
        /// <returns>
        /// A <see cref="System.Boolean"/>
        /// </returns>
        private static bool IsHostReachable(string host)
        {
            if (host == null || host.Length == 0)
                return false;

            using (var r = new NetworkReachability (host)){
                NetworkReachabilityFlags flags;

                if (r.TryGetFlags (out flags)){
                    return IsReachable (flags) && IsNoConnectionRequired(flags);  // is reachable without requiring connection.
                }
            }
            return false;
        }
    // Update is called once per frame
    void Update()
    {
        if (Application.internetReachability == NetworkReachability.NotReachable || GameUpdate.Instance != null)
        {
            if (CurNetworkType != NetworkReachability.NotReachable)
            {
                //  UIManager.Instance.ShowUiPanel(UIPaths.ReconectTipPanel);
            }

            CurNetworkType = NetworkReachability.NotReachable;

            // UIManager.Instance.ShowUiPanel(UIPaths.ReconectTipPanel);
        }
        else if (Application.internetReachability == NetworkReachability.ReachableViaCarrierDataNetwork)
        {
            if (CurNetworkType != NetworkReachability.ReachableViaCarrierDataNetwork)
            {
                ConnServer.Instance.DisconnectServer();
                // AndroidOrIOSResult.GetMask();
                intervalTime = 0;
            }
            CurNetworkType = NetworkReachability.ReachableViaCarrierDataNetwork;
            if (!ConnServer.m_IsConnectServer)//断开服务器
            {
                if (intervalTime <= 0)
                {
                    intervalTime = 3;
                    ConnServer.m_WaitServerMsgCount = 0;
                    if (ServerInfo.Data.ip != null)
                    {
                        ConnServer.ConnectionServer(ToolsFunc.GetServerIP(ServerInfo.Data.ip), ServerInfo.Data.port);
                    }
                }
                else
                {
                    intervalTime -= Time.deltaTime;
                }
            }

            //  UIManager.Instance.HideUiPanel(UIPaths.ReconectTipPanel);
        }
        else if (Application.internetReachability == NetworkReachability.ReachableViaLocalAreaNetwork)
        {
            if (CurNetworkType != NetworkReachability.ReachableViaLocalAreaNetwork)
            {
                ConnServer.Instance.DisconnectServer();
                //  AndroidOrIOSResult.GetMask();
                intervalTime = 0;
            }
            CurNetworkType = NetworkReachability.ReachableViaLocalAreaNetwork;
            if (!ConnServer.m_IsConnectServer)//断开服务器
            {
                if (intervalTime <= 0)
                {
                    intervalTime = 3;
                    ConnServer.m_WaitServerMsgCount = 0;
                    if (ServerInfo.Data.ip != null)
                    {
                        ConnServer.ConnectionServer(ToolsFunc.GetServerIP(ServerInfo.Data.ip), ServerInfo.Data.port);
                    }
                }
                else
                {
                    intervalTime -= Time.deltaTime;
                }
            }

            //    UIManager.Instance.HideUiPanel(UIPaths.ReconectTipPanel);
        }
    }
Exemplo n.º 21
0
 public InternetService()
 {
     _defaultRoute = new NetworkReachability(new IPAddress(0));
 }
Exemplo n.º 22
0
        IEnumerator PrepareTask(System.Action finishCallback, System.Action loadFailCallback, bool onlineUpdate = false)
        {
            bool err                     = false;
            bool hasTempCopy             = false;
            NetworkReachability netState = Application.internetReachability;
            bool isGameReadyToComplete   = PlayerPrefs.GetInt("GameReadyToComplete", 0) == 1;

            _progress.CurrentState = ProgressState.Init;
            CustomAssetBundleManifest tempManifest   = null;
            CustomAssetBundleManifest localManifest  = null;
            CustomAssetBundleManifest serverManifest = null;

            #region prepare manifest file
            string scenePath          = System.IO.Path.Combine(AssetBundleConfig.PersistentDataPath, "Scene.unity3d").Replace("\\", "/");
            string tempManifestPath   = System.IO.Path.Combine(AssetBundleConfig.PersistentDataPathTemp, AssetBundleConfig.ManifestRelativePath).Replace("\\", "/");
            string localManifestPath  = System.IO.Path.Combine(AssetBundleConfig.PersistentDataPath, AssetBundleConfig.ManifestRelativePath).Replace("\\", "/");
            string serverManifestPath = System.IO.Path.Combine(AssetBundleConfig.ServerAssetsPath, AssetBundleConfig.ManifestRelativePath).Replace("\\", "/");

            #region  获取默认的manifest,PersistentDataPath/Temp
            //temp manifest--- a copy of manifest in streamassets
            if (!File.Exists(tempManifestPath) || !isGameReadyToComplete)
            {
                Debug.Log("temp copy of manifest");
                yield return(StartCoroutine(Helpers.PathUtil.CopyFileFromAppPathAsync(AssetBundleConfig.ManifestRelativePath, AssetBundleConfig.StreamingAssetsPath, AssetBundleConfig.PersistentDataPathTemp)));
            }
            if (!File.Exists(tempManifestPath))
            {
                yield return(null);
            }
            TextAsset tempTextAsset = LoadLocalAsset <TextAsset>(tempManifestPath, AssetBundleConfig.ManifestName);
            if (tempTextAsset != null)
            {
                Debug.Log("has temp copy");
                hasTempCopy  = true;
                tempManifest = CustomAssetBundleManifest.CreateInstance(tempTextAsset.bytes);
            }
            #endregion

            #region 获取本地manifest,PersistentDataPath
            //local manifest
            if (System.IO.File.Exists(localManifestPath) && isGameReadyToComplete)
            {
                Debug.Log("have localmanifest");
                tempTextAsset = LoadLocalAsset <TextAsset>(localManifestPath, AssetBundleConfig.ManifestName);
                localManifest = CustomAssetBundleManifest.CreateInstance(tempTextAsset.bytes);
            }
            #endregion

            #region 获取资源服务器manifest,ServerPath
            //server manifest
            if (netState != NetworkReachability.NotReachable && onlineUpdate)
            {
                PlayerPrefs.SetInt("GameReadyToComplete", 0);
                yield return(null);

                string sourcePath = Path.Combine(AssetBundleConfig.ServerAssetsPath, AssetBundleConfig.ManifestRelativePath).Replace("\\", "/");
                using (UnityWebRequest www = UnityWebRequest.Get(sourcePath))
                {
                    //www.timeout = 30;//设置超时,www.SendWebRequest()连接超时会返回,且isNetworkError为true
                    yield return(www.SendWebRequest());

                    if (www.isNetworkError)
                    {
                        Debug.Log("Download Error:" + www.error);
                        err = true;
                    }
                    else //if (www.responseCode == 200)//200表示接受成功
                    {
                        Debug.Log("Download no error");
                        byte[] bytes = www.downloadHandler.data;
                        Helpers.PathUtil.CopyBufferToFile(bytes, localManifestPath);
                        var ab = AssetBundle.LoadFromMemory(bytes);
                        var tx = ab.LoadAsset <TextAsset>(AssetBundleConfig.ManifestName);
                        serverManifest = CustomAssetBundleManifest.CreateInstance(tx.bytes);
                        ab.Unload(true);
                    }
                }
            }
            #endregion

            #region 非网络状态检查本地manifest
            if (err || netState == NetworkReachability.NotReachable || !onlineUpdate)
            {
                err = false;
                if (localManifest != null && isGameReadyToComplete) //包含完整本地资源
                {
                }
                else if (localManifest == null && hasTempCopy)      //包含默认资源
                {
                    Debug.Log("包含默认资源");
                    Helpers.PathUtil.CopyFile(tempManifestPath, localManifestPath);
                }
                else                                                //没有任何资源
                {
                    //throw new Exception("not contain default resources");
                    err = true;
                }
            }
            #endregion

            #endregion
            if (err)
            {
                loadFailCallback();
            }
            else
            {
                bool          IsCompressed        = true;
                List <string> needLoadFromServer  = new List <string>();
                List <string> needLoadFromDefault = new List <string>();
                if (serverManifest != null)
                {
                    IsCompressed = serverManifest.IsCompressed;
                    if (!isGameReadyToComplete && localManifest != null)//上次更新资源没有完全准备好
                    {
                        localManifest.AssetMap.Clear();
                    }
                    List <string> loadFromServer     = CustomAssetBundleManifest.GetDifference(localManifest, serverManifest);
                    List <string> canLoadFromDefault = CustomAssetBundleManifest.GetSame(tempManifest, serverManifest);
                    foreach (var item in loadFromServer)
                    {
                        if (canLoadFromDefault.Contains(item))
                        {
                            needLoadFromDefault.Add(item);
                        }
                        else
                        {
                            Debug.Log("needloadfromserver:" + item);
                            needLoadFromServer.Add(item);
                        }
                    }
                }
                else if (localManifest == null && hasTempCopy)
                {
                    IsCompressed = tempManifest.IsCompressed;
                    List <string> loadFromDefault = new List <string>();
                    using (var itr = tempManifest.AssetMap.GetEnumerator())
                    {
                        while (itr.MoveNext())
                        {
                            loadFromDefault.Add(itr.Current.Key);
                        }
                    }
                    needLoadFromDefault = loadFromDefault;
                }
                else if (localManifest != null && hasTempCopy)
                {
                    IsCompressed        = tempManifest.IsCompressed;
                    needLoadFromDefault = GetLocalWithDefaultDifference(localManifest, tempManifest);
                    Debug.Log("PathHelper.CopyFile");
                    Helpers.PathUtil.CopyFile(tempManifestPath, localManifestPath);
                }
                _progress.CurrentStep  = 0;
                _progress.AllStepCount = needLoadFromDefault.Count + needLoadFromServer.Count;
                Debug.Log("allstepcount:" + _progress.AllStepCount + needLoadFromDefault.Count + needLoadFromServer.Count);
                if (serverManifest != null)
                {
                    yield return(StartCoroutine(DownloadAssetBundle(needLoadFromServer, AssetBundleConfig.ServerAssetsPath, AssetBundleConfig.PersistentDataPath, IsCompressed)));
                }
                yield return(StartCoroutine(CopyAssetBundle(needLoadFromDefault, AssetBundleConfig.PersistentDataPath, IsCompressed)));

                _progress.CurrentState = ProgressState.Done;
                Helpers.PathUtil.DeleteDir(AssetBundleConfig.PersistentDataPathTemp);
                PlayerPrefs.SetInt("GameReadyToComplete", 1);
                yield return(null);

                if (finishCallback != null)
                {
                    finishCallback();
                }
                Destroy(gameObject);
            }
        }
Exemplo n.º 23
0
 /** 是否为某种网络类型 */
 public static bool isSomeNetWork(NetworkReachability net)
 {
     return(_lastNet == net);
 }
Exemplo n.º 24
0
 private void Start()
 {
     reachability = Application.internetReachability;
     UnPause();
 }
Exemplo n.º 25
0
 private void NetWorkChange(NetworkReachability preNetWorkStatus, NetworkReachability internetReachability)
 {
     registerText.text = "网络状态变化时触发===》" + internetReachability.ToString();
 }
Exemplo n.º 26
0
    public override void DoUpdate()
    {
        base.DoUpdate();
        if (Application.internetReachability == NetworkReachability.NotReachable)
        {
            _curNetworkType = NetworkReachability.NotReachable;
            if (Application.internetReachability == NetworkReachability.NotReachable)
            {
                //GameConfig.ResultCodeStr = "本机没有网络数据";
                //UIManager.Instance.ShowSync(UIPaths.ResultCodeDialog, OpenPanelType.MinToMax);
            }

            // UIManager.Instance.ShowUiPanel(UIPaths.ReconectTipPanel);
        }
        else if (Application.internetReachability == NetworkReachability.ReachableViaCarrierDataNetwork)
        {
            if (_curNetworkType != NetworkReachability.ReachableViaCarrierDataNetwork)
            {
                NetConnectServer.Instance.DisconnectServer();
                // AndroidOrIOSResult.GetMask();
                IntervalTime = 0;
            }
            _curNetworkType = NetworkReachability.ReachableViaCarrierDataNetwork;
            if (!NetConnectServer.IsConnectServer)//断开服务器
            {
                if (IntervalTime <= 0)
                {
                    IntervalTime = 3;
                    NetConnectServer.WaitServerMsgCount = 0;
                    if (NetServerInfo.Instance.ip != null)
                    {
                        NetConnectServer.ConnectionServer(Tool.GetServerIp(NetServerInfo.Instance.ip), NetServerInfo.Instance.port);
                    }
                }
                else
                {
                    IntervalTime -= Time.deltaTime;
                }
            }
            //  UIManager.Instance.HideUiPanel(UIPaths.ReconectTipPanel);
        }
        else if (Application.internetReachability == NetworkReachability.ReachableViaLocalAreaNetwork)
        {
            if (_curNetworkType != NetworkReachability.ReachableViaLocalAreaNetwork)
            {
                NetConnectServer.Instance.DisconnectServer();
                //  AndroidOrIOSResult.GetMask();
                IntervalTime = 0;
            }
            _curNetworkType = NetworkReachability.ReachableViaLocalAreaNetwork;
            if (!NetConnectServer.IsConnectServer)//断开服务器
            {
                if (IntervalTime <= 0)
                {
                    IntervalTime = 3;
                    NetConnectServer.WaitServerMsgCount = 0;
                    if (NetServerInfo.Instance.ip != null)
                    {
                        NetConnectServer.ConnectionServer(Tool.GetServerIp(NetServerInfo.Instance.ip), NetServerInfo.Instance.port);
                    }
                }
                else
                {
                    IntervalTime -= Time.deltaTime;
                }
            }

            //    UIManager.Instance.HideUiPanel(UIPaths.ReconectTipPanel);
        }
    }
Exemplo n.º 27
0
 public override void DoStart()
 {
     base.DoStart();
     _curNetworkType = Application.internetReachability;
 }
Exemplo n.º 28
0
 void NetworkReachabilityChanged(NetworkReachability _)
 {
     UpdateButtonInteractable();
 }
Exemplo n.º 29
0
        // Is the host reachable with the current network configuration
        public static bool IsHostReachable(string host)
        {
            if (host == null || host.Length == 0)
             return false;

            #if WINDOWS_PHONE
             //I know I know, but I'm trying to keep the behavior the same across platforms
             bool done = false;
             bool reachable = false;
             DeviceNetworkInformation.ResolveHostNameAsync(new DnsEndPoint(HostName, 80), (x) => {
             done = true;
             if (x.NetworkErrorCode == NetworkError.Success)
             reachable = true;
             else
             reachable = false;
             }, null);

             while (!done) { Thread.Sleep(200); }

             return reachable;

            #elif IPHONE

             using (var r = new NetworkReachability (host)){
             NetworkReachabilityFlags flags;

             if (r.TryGetFlags (out flags)){
             return IsReachableWithoutRequiringConnection (flags);
             }
             }
             return false;
            #else
             var test = new Ping();
             var reply = test.Send(HostName);

             if (reply.Status == IPStatus.Success)
             return true;
             else
             return false;
            #endif
        }
 public ApplicationSimulation(SimulatorState serializedState)
 {
     simulatedSystemLanguage       = serializedState.systemLanguage;
     simulatedInternetReachability = serializedState.networkReachability;
 }
Exemplo n.º 31
0
        /// <summary>
        /// This method processes queued web requests and user callbacks.
        /// </summary>
        void ProcessRequests()
        {
            // TODO : The current implementation dequeues a single request and callback per cycle
            // to reduce the CPU utilization of the main thread by the UnityMainThreadDispatcher.
            // Need to do perf testing to to verify if this is the best approach.

            // Make a network call for queued requests on the main thread
            var request = UnityRequestQueue.Instance.DequeueRequest();

            if (request != null)
            {
                StartCoroutine(InvokeRequest(request));
            }

            // Invoke queued callbacks on the main thread
            var asyncResult = UnityRequestQueue.Instance.DequeueCallback();

            if (asyncResult != null && asyncResult.Action != null)
            {
                try
                {
                    asyncResult.Action(asyncResult.Request, asyncResult.Response,
                                       asyncResult.Exception, asyncResult.AsyncOptions);
                }
                catch (Exception exception)
                {
                    // Catch any unhandled exceptions from the user callback
                    // and log it.
                    _logger.Error(exception,
                                  "An unhandled exception was thrown from the callback method {0}.",
                                  asyncResult.Request.ToString());
                }
            }

            //Invoke queued main thread executions
            var mainThreadCallback = UnityRequestQueue.Instance.DequeueMainThreadOperation();

            if (mainThreadCallback != null)
            {
                try
                {
                    mainThreadCallback();
                }
                catch (Exception exception)
                {
                    // Catch any unhandled exceptions from the user callback
                    // and log it.
                    _logger.Error(exception,
                                  "An unhandled exception was thrown from the callback method");
                }
            }

            //network updates
            //TODO: need to check for performance
            NetworkReachability _networkReachability = Application.internetReachability;

            if (OnRefresh != null)
            {
                OnRefresh(this, new NetworkStatusRefreshed(_networkReachability));
            }
        }
Exemplo n.º 32
0
        //public NetworkReachability curState = NetworkReachability.ReachableViaCarrierDataNetwork;

        public override void OnInitialize()
        {
            //NetworkTransport.Init();
            lastState = Reachability;
        }
Exemplo n.º 33
0
 private void Start()
 {
     CurrentReachability = Application.internetReachability;
 }
Exemplo n.º 34
0
    public static NetworkStatus RemoteHostStatus()
    {
        NetworkReachabilityFlags flags;
        bool reachable;

        if (remoteHostReachability == null)
        {
            remoteHostReachability = new NetworkReachability (HostName);

            reachable = remoteHostReachability.TryGetFlags (out flags);

            remoteHostReachability.SetCallback (OnChange);
            remoteHostReachability.Schedule (CFRunLoop.Current, CFRunLoop.ModeDefault);
        }
        else
            reachable = remoteHostReachability.TryGetFlags (out flags);

        if (!reachable)
            return NetworkStatus.NotReachable;

        if (!IsReachableWithoutRequiringConnection (flags))
            return NetworkStatus.NotReachable;

        if ((flags & NetworkReachabilityFlags.IsWWAN) != 0)
            return NetworkStatus.ReachableViaCarrierDataNetwork;

        return NetworkStatus.ReachableViaWiFiNetwork;
    }
Exemplo n.º 35
0
 void NetworkReachabilityChanged(NetworkReachability _)
 {
     UpdateProfile();
 }
Exemplo n.º 36
0
 public NetworkManager()
 {
     mNetState = Application.internetReachability;
 }
Exemplo n.º 37
0
		public Connection ()
		{
			NetworkReachability = new NetworkReachability (new IPAddress (0));

		}
 public void ApplicationDidBecomeActive(NetworkReachability.Notification notifaction)
 {
     Show();
 }
 void Start()
 {
     CurNetworkType = Application.internetReachability;
 }
 public void ApplicationWillResignActive(NetworkReachability.Notification notifaction)
 {
     // We hide temporary when the application resigns active s.t the overlay
     // doesn't overlay the Notification Center. Let's hope this helps AppStore
     // Approval ...
     HideTemporary();
 }
Exemplo n.º 41
0
        /// <summary>
        /// 
        /// </summary>
        /// <param name="flags">
        /// A <see cref="NetworkReachabilityFlags"/>
        /// </param>
        /// <returns>
        /// A <see cref="System.Boolean"/>
        /// </returns>
        private static bool IsAdHocWiFiNetworkAvailable(out NetworkReachabilityFlags flags)
        {
            NetworkReachability adHocWiFiNetworkReachability = new NetworkReachability (new IPAddress (new byte [] {169,254,0,0}));

            if (!adHocWiFiNetworkReachability.TryGetFlags (out flags))
                return false;

            return IsReachable (flags) && IsNoConnectionRequired(flags);  // is reachable without requiring connection.
        }
Exemplo n.º 42
0
 /// <summary>
 /// 初始化管理器
 /// </summary>
 protected override void Init()
 {
     _networkReachability = Application.internetReachability;
 }
Exemplo n.º 43
0
        /// <summary>
        /// 
        /// </summary>
        /// <param name="flags">
        /// A <see cref="NetworkReachabilityFlags"/>
        /// </param>
        /// <returns>
        /// A <see cref="System.Boolean"/>
        /// </returns>
        private static bool IsNetworkAvaialable(out NetworkReachabilityFlags flags)
        {
            NetworkReachability defaultRouteReachability = new NetworkReachability (new IPAddress (0));

            if (defaultRouteReachability.TryGetFlags (out flags))
                return false;
            return IsReachable (flags) && IsNoConnectionRequired(flags);  // is reachable without requiring connection.
        }
        public static NetworkStatus RemoteHostStatus(string HostName)
        {
            NetworkReachabilityFlags flags;
            bool reachable;

            if (remoteHostReachability == null) {
                remoteHostReachability = new NetworkReachability (HostName);

                // Need to probe before we queue, or we wont get any meaningful values
                // this only happens when you create NetworkReachability from a hostname
                reachable = remoteHostReachability.TryGetFlags (out flags);

                remoteHostReachability.SetCallback (OnChange);
                remoteHostReachability.Schedule (CFRunLoop.Current, CFRunLoop.ModeDefault);
            } else
                reachable = remoteHostReachability.TryGetFlags (out flags);

            if (!reachable)
                return NetworkStatus.NotReachable;

            if (!IsReachableWithoutRequiringConnection (flags))
                return NetworkStatus.NotReachable;

            if ((flags & NetworkReachabilityFlags.IsWWAN) != 0)
                return NetworkStatus.ReachableViaCarrierDataNetwork;

            return NetworkStatus.ReachableViaWiFiNetwork;
        }
        public void CtorIPAddressPair()
        {
            var address = Dns.GetHostAddresses("apple.com")[0];

            using (var nr = new NetworkReachability(IPAddress.Loopback, address))
            {
                NetworkReachabilityFlags flags;

                Assert.IsTrue(nr.TryGetFlags(out flags), "#1");
                // using Loopback iOS 10 / tvOS 10 returns no flags (0) on devices
#if !MONOMAC
                if ((Runtime.Arch == Arch.DEVICE) && TestRuntime.CheckXcodeVersion(8, 0))
                {
                    Assert.That((int)flags, Is.EqualTo(0), "#1 Reachable");
                }
                else
#endif
                Assert.That(flags, Is.EqualTo(NetworkReachabilityFlags.Reachable), "#1 Reachable");
            }

            using (var nr = new NetworkReachability(null, address))
            {
                NetworkReachabilityFlags flags;

                Assert.IsTrue(nr.TryGetFlags(out flags), "#2");
                Assert.That(flags, Is.EqualTo(NetworkReachabilityFlags.Reachable), "#2 Reachable");
            }

            using (var nr = new NetworkReachability(IPAddress.Loopback, null))
            {
                NetworkReachabilityFlags flags;

                Assert.IsTrue(nr.TryGetFlags(out flags), "#3");
                // using Loopback iOS 10 / tvOS 10 / macOS 10.12 returns no flags (0) on devices
                var expected = (NetworkReachabilityFlags)0;
#if MONOMAC
                if (!TestRuntime.CheckSystemVersion(PlatformName.MacOSX, 10, 12))
                {
                    expected = NetworkReachabilityFlags.Reachable;
                    if (!TestRuntime.CheckSystemVersion(PlatformName.MacOSX, 10, 11))
                    {
                        expected |= NetworkReachabilityFlags.IsLocalAddress;
                    }
                }
#else
                if ((Runtime.Arch == Arch.DEVICE) && TestRuntime.CheckXcodeVersion(8, 0))
                {
                    //
                }
                else
                {
                    expected = NetworkReachabilityFlags.Reachable;
                    if (!TestRuntime.CheckXcodeVersion(7, 0))
                    {
                        expected |= NetworkReachabilityFlags.IsLocalAddress;
                    }
                }
#endif
                Assert.That(flags, Is.EqualTo(expected), "#3 Reachable");
            }
        }
Exemplo n.º 46
0
        /// <summary>
        /// Checks ad hoc wifi is available
        /// </summary>
        /// <param name="flags"></param>
        /// <returns></returns>
        public static bool IsAdHocWiFiNetworkAvailable(out NetworkReachabilityFlags flags)
        {
            if (adHocWiFiNetworkReachability == null)
            {
                //var ip = IPAddress.Parse("::ffff:169.254.0.0");
                var data = new byte[] { 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 255, 255, 169, 254, 0, 0 };
                var ip = new IPAddress(data, 0);
                adHocWiFiNetworkReachability = new NetworkReachability(ip);
                adHocWiFiNetworkReachability.SetNotification(OnChange);
                adHocWiFiNetworkReachability.Schedule(CFRunLoop.Main, CFRunLoop.ModeDefault);
            }

            if (!adHocWiFiNetworkReachability.TryGetFlags(out flags))
                return false;

            return IsReachableWithoutRequiringConnection(flags);
        }
        public void TestInternetReachability(NetworkReachability internetReachability)
        {
            m_ApplicationSimulation.ShimmedInternetReachability = internetReachability;

            Assert.AreEqual(internetReachability, Application.internetReachability);
        }
Exemplo n.º 48
0
        static bool IsNetworkAvailable(out NetworkReachabilityFlags flags)
        {

            if (defaultRouteReachability == null)
            {
                var data = new byte[] { 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 255, 255, 0, 0, 0, 0 };
                var ip = new IPAddress(data, 0);
                defaultRouteReachability = new NetworkReachability(ip);
                defaultRouteReachability.SetNotification(OnChange);
                defaultRouteReachability.Schedule(CFRunLoop.Main, CFRunLoop.ModeDefault);
            }
            if (!defaultRouteReachability.TryGetFlags(out flags))
                return false;
            return IsReachableWithoutRequiringConnection(flags);
        }
Exemplo n.º 49
0
    public void In(
        [FriendlyName("levelCount", "The total number of levels available.")]
        [SocketState(false, false)]
        out int levelCount,

        [FriendlyName("loadedLevel", "The level index that was last loaded.")]
        [SocketState(false, false)]
        out int[] loadedLevels,

        [FriendlyName("loadedLevelName", "The name of the level that was last loaded.")]
        [SocketState(false, false)]
        out string[] loadedLevelNames,

        [FriendlyName("isEditor", "Are we running inside the Unity editor?")]
        [SocketState(false, false)]
        out bool isEditor,

        [FriendlyName("isPlaying", "Returns true when in any kind of player.")]
        [SocketState(false, false)]
        out bool isPlaying,

        [FriendlyName("isWebPlayer", "Are we running inside a web player?")]
        [SocketState(false, false)]
        out bool isWebPlayer,

        [FriendlyName("streamedBytes", "Returns the number of bytes that have been downloaded from the main unity web stream.")]
        [SocketState(false, false)]
        out int streamedBytes,

        [FriendlyName("platform", "Returns the platform the game is running (Read Only).")]
        [SocketState(false, false)]
        out RuntimePlatform platform,

        [FriendlyName("dataPath", "Contains the path to the game data folder (Read Only).")]
        [SocketState(false, false)]
        out string dataPath,

        [FriendlyName("persistentDataPath", "Contains the path to a persistent data directory (Read Only).")]
        [SocketState(false, false)]
        out string persistentDataPath,

        [FriendlyName("temporaryCachePath", "Contains the path to a temporary data / cache directory (Read Only).")]
        [SocketState(false, false)]
        out string temporaryCachePath,

        [FriendlyName("srcValue", "The path to the web player data file relative to the html file (Read Only).")]
        [SocketState(false, false)]
        out string srcValue,

        [FriendlyName("absoluteURL", "The absolute path to the web player data file (Read Only).")]
        [SocketState(false, false)]
        out string absoluteURL,

        [FriendlyName("systemLanguage", "The language the user's operating system is running in.")]
        [SocketState(false, false)]
        out SystemLanguage systemLanguage,

        [FriendlyName("internetReachability", "Returns internet reachability status.")]
        [SocketState(false, false)]
        out NetworkReachability internetReachability,

        [FriendlyName("webSecurityEnabled", "Indicates whether Unity's webplayer security model is enabled.")]
        [SocketState(false, false)]
        out bool webSecurityEnabled,

        [FriendlyName("webSecurityHostUrl", "[This appears to be undocumented!]")]
        [SocketState(false, false)]
        out string webSecurityHostUrl,

        [FriendlyName("runInBackground", "Returns the application background play state.")]
        [SocketState(false, false)]
        out bool runInBackground,

        [FriendlyName("targetFrameRate", "Returns the frame rate the game is instructed to use. The value is the ideal frame rate and may not reflect the actual frame rate.")]
        [SocketState(false, false)]
        out int targetFrameRate,

        [FriendlyName("backgroundLoadingPriority", "Returns the priority of background loading thread.")]
        [SocketState(false, false)]
        out ThreadPriority backgroundLoadingPriority,

        [FriendlyName("unityVersion", "The version of the Unity runtime used to play the content.")]
        out string unityVersion
        )
    {
        levelCount = UnityEngine.SceneManagement.SceneManager.sceneCountInBuildSettings;

#if UNITY_5_3_0
        UnityEngine.SceneManagement.Scene[] scenes = UnityEngine.SceneManagement.SceneManager.GetAllScenes();
        loadedLevels     = new int[scenes.Length];
        loadedLevelNames = new string[scenes.Length];

        for (int i = 0; i < scenes.Length; i++)
        {
            loadedLevels[i]     = scenes[i].buildIndex;
            loadedLevelNames[i] = scenes[i].name;
        }
#else
        loadedLevels     = new int[UnityEngine.SceneManagement.SceneManager.sceneCount];
        loadedLevelNames = new string[UnityEngine.SceneManagement.SceneManager.sceneCount];

        for (int i = 0; i < UnityEngine.SceneManagement.SceneManager.sceneCount; i++)
        {
            UnityEngine.SceneManagement.Scene scene = UnityEngine.SceneManagement.SceneManager.GetSceneAt(i);
            loadedLevels[i]     = scene.buildIndex;
            loadedLevelNames[i] = scene.name;
        }
#endif

        isEditor = Application.isEditor;

        isPlaying     = Application.isPlaying;
        isWebPlayer   = Application.isWebPlayer;
        streamedBytes = Application.streamedBytes;

        platform           = Application.platform;
        dataPath           = Application.dataPath;
        persistentDataPath = Application.persistentDataPath;
        temporaryCachePath = Application.temporaryCachePath;

        srcValue       = Application.srcValue;
        absoluteURL    = Application.absoluteURL;
        unityVersion   = Application.unityVersion;
        systemLanguage = Application.systemLanguage;

        internetReachability = Application.internetReachability;

#if !(UNITY_5_5_OR_NEWER || UNITY_2017)
        webSecurityEnabled = Application.webSecurityEnabled;
        webSecurityHostUrl = Application.webSecurityHostUrl;
#else
        webSecurityEnabled = false;
        webSecurityHostUrl = "";
#endif

        backgroundLoadingPriority = Application.backgroundLoadingPriority;
        runInBackground           = Application.runInBackground;
        targetFrameRate           = Application.targetFrameRate;
    }
Exemplo n.º 50
0
        /// <summary>
        /// Dispose
        /// </summary>
        public static void Dispose()
        {
            if (remoteHostReachability != null)
            {
                remoteHostReachability.Dispose();
                remoteHostReachability = null;
            }

            if (defaultRouteReachability != null)
            {
                defaultRouteReachability.Dispose();
                defaultRouteReachability = null;
            }

            if (adHocWiFiNetworkReachability != null)
            {
                adHocWiFiNetworkReachability.Dispose();
                adHocWiFiNetworkReachability = null;
            }
        }
Exemplo n.º 51
0
        private static bool IsNetworkAvaialable(out NetworkReachabilityFlags flags)
        {
            if (defaultRouteReachability == null)
            {
                defaultRouteReachability = new NetworkReachability(new IPAddress(0));
#warning Need to look at SetNotification instead - ios6 change
                defaultRouteReachability.SetNotification(OnChange);
                defaultRouteReachability.Schedule(CFRunLoop.Current, CFRunLoop.ModeDefault);
            }
            if (defaultRouteReachability.TryGetFlags(out flags))
                return false;
            return IsReachableWithoutRequiringConnection(flags);
        }
 void NetworkReachabilityChanged(NetworkReachability _)
 {
     UpdateButtonInteractable(m_ToolBarEnabledSelector.GetValue());
 }
 public NetworkStatusRefreshed(NetworkReachability reachability)
 {
     NetworkReachability = reachability;
 }
 public void Init()
 {
     isAwake      = true;
     reachability = NetworkReachability.NotReachable;
     InvokeRepeating("CheckInternet", frequency, frequency);
 }
Exemplo n.º 55
0
    public void In(
        [FriendlyName("levelCount", "The total number of levels available.")]
        [SocketState(false, false)]
        out int levelCount,

        [FriendlyName("loadedLevel", "The level index that was last loaded.")]
        [SocketState(false, false)]
        out int loadedLevel,

        [FriendlyName("loadedLevelName", "The name of the level that was last loaded.")]
        [SocketState(false, false)]
        out string loadedLevelName,

        [FriendlyName("isEditor", "Are we running inside the Unity editor?")]
        [SocketState(false, false)]
        out bool isEditor,

        [FriendlyName("isLoadingLevel", "Is some level being loaded?")]
        [SocketState(false, false)]
        out bool isLoadingLevel,

        [FriendlyName("isPlaying", "Returns true when in any kind of player.")]
        [SocketState(false, false)]
        out bool isPlaying,

        [FriendlyName("isWebPlayer", "Are we running inside a web player?")]
        [SocketState(false, false)]
        out bool isWebPlayer,

        [FriendlyName("streamedBytes", "Returns the number of bytes that have been downloaded from the main unity web stream.")]
        [SocketState(false, false)]
        out int streamedBytes,

        [FriendlyName("platform", "Returns the platform the game is running (Read Only).")]
        [SocketState(false, false)]
        out RuntimePlatform platform,

        [FriendlyName("dataPath", "Contains the path to the game data folder (Read Only).")]
        [SocketState(false, false)]
        out string dataPath,

        [FriendlyName("persistentDataPath", "Contains the path to a persistent data directory (Read Only).")]
        [SocketState(false, false)]
        out string persistentDataPath,

        [FriendlyName("temporaryCachePath", "Contains the path to a temporary data / cache directory (Read Only).")]
        [SocketState(false, false)]
        out string temporaryCachePath,

        [FriendlyName("srcValue", "The path to the web player data file relative to the html file (Read Only).")]
        [SocketState(false, false)]
        out string srcValue,

        [FriendlyName("absoluteURL", "The absolute path to the web player data file (Read Only).")]
        [SocketState(false, false)]
        out string absoluteURL,

        [FriendlyName("systemLanguage", "The language the user's operating system is running in.")]
        [SocketState(false, false)]
        out SystemLanguage systemLanguage,

        //allow for 3_4 and higher
#if !UNITY_3_2 && !UNITY_3_3
        [FriendlyName("internetReachability", "Returns internet reachability status.")]
        [SocketState(false, false)]
        out NetworkReachability internetReachability,
#endif
        [FriendlyName("webSecurityEnabled", "Indicates whether Unity's webplayer security model is enabled.")]
        [SocketState(false, false)]
        out bool webSecurityEnabled,

        [FriendlyName("webSecurityHostUrl", "[This appears to be undocumented!]")]
        [SocketState(false, false)]
        out string webSecurityHostUrl,

        [FriendlyName("runInBackground", "Returns the application background play state.")]
        [SocketState(false, false)]
        out bool runInBackground,

        [FriendlyName("targetFrameRate", "Returns the frame rate the game is instructed to use. The value is the ideal frame rate and may not reflect the actual frame rate.")]
        [SocketState(false, false)]
        out int targetFrameRate,

        [FriendlyName("backgroundLoadingPriority", "Returns the priority of background loading thread.")]
        [SocketState(false, false)]
        out ThreadPriority backgroundLoadingPriority,

        [FriendlyName("unityVersion", "The version of the Unity runtime used to play the content.")]
        out string unityVersion
        )
    {
        levelCount      = Application.levelCount;
        loadedLevel     = Application.loadedLevel;
        loadedLevelName = Application.loadedLevelName;

        isEditor       = Application.isEditor;
        isLoadingLevel = Application.isLoadingLevel;
        isPlaying      = Application.isPlaying;
        isWebPlayer    = Application.isWebPlayer;
        streamedBytes  = Application.streamedBytes;

        platform           = Application.platform;
        dataPath           = Application.dataPath;
        persistentDataPath = Application.persistentDataPath;
        temporaryCachePath = Application.temporaryCachePath;

        srcValue       = Application.srcValue;
        absoluteURL    = Application.absoluteURL;
        unityVersion   = Application.unityVersion;
        systemLanguage = Application.systemLanguage;

        //allow for 3_4 and higher
      #if !UNITY_3_2 && !UNITY_3_3
        internetReachability = Application.internetReachability;
      #endif

        webSecurityEnabled = Application.webSecurityEnabled;
        webSecurityHostUrl = Application.webSecurityHostUrl;

        backgroundLoadingPriority = Application.backgroundLoadingPriority;
        runInBackground           = Application.runInBackground;
        targetFrameRate           = Application.targetFrameRate;
    }
Exemplo n.º 56
0
 public int GetStatistics(NetworkReachability networkType)
 {
     return(CSocket.GetSendStatistics(networkType) + CSocket.GetRecvStatistics(networkType));
 }
    public void In(
        [FriendlyName("levelCount", "The total number of levels available.")]
        [SocketState(false, false)]
        out int levelCount,

        [FriendlyName("loadedLevel", "The level index that was last loaded.")]
        [SocketState(false, false)]
        out int loadedLevel,

        [FriendlyName("loadedLevelName", "The name of the level that was last loaded.")]
        [SocketState(false, false)]
        out string loadedLevelName,

        [FriendlyName("isEditor", "Are we running inside the Unity editor?")]
        [SocketState(false, false)]
        out bool isEditor,

        // This functionality was depricated in 5.2. You now need to specify a level index, so for
        // general application reporting you can no longer find out if ANY level might be currently loading, which
        // is what this node's intention to report out from this socket was for.
#if (UNITY_3_5 || UNITY_4_6 || UNITY_4_7 || UNITY_5_0 || UNITY_5_1)
        [FriendlyName("isLoadingLevel", "Is some level being loaded?")]
        [SocketState(false, false)]
        out bool isLoadingLevel,
#endif
        [FriendlyName("isPlaying", "Returns true when in any kind of player.")]
        [SocketState(false, false)]
        out bool isPlaying,

        [FriendlyName("isWebPlayer", "Are we running inside a web player?")]
        [SocketState(false, false)]
        out bool isWebPlayer,

        [FriendlyName("streamedBytes", "Returns the number of bytes that have been downloaded from the main unity web stream.")]
        [SocketState(false, false)]
        out int streamedBytes,

        [FriendlyName("platform", "Returns the platform the game is running (Read Only).")]
        [SocketState(false, false)]
        out RuntimePlatform platform,

        [FriendlyName("dataPath", "Contains the path to the game data folder (Read Only).")]
        [SocketState(false, false)]
        out string dataPath,

        [FriendlyName("persistentDataPath", "Contains the path to a persistent data directory (Read Only).")]
        [SocketState(false, false)]
        out string persistentDataPath,

        [FriendlyName("temporaryCachePath", "Contains the path to a temporary data / cache directory (Read Only).")]
        [SocketState(false, false)]
        out string temporaryCachePath,

        [FriendlyName("srcValue", "The path to the web player data file relative to the html file (Read Only).")]
        [SocketState(false, false)]
        out string srcValue,

        [FriendlyName("absoluteURL", "The absolute path to the web player data file (Read Only).")]
        [SocketState(false, false)]
        out string absoluteURL,

        [FriendlyName("systemLanguage", "The language the user's operating system is running in.")]
        [SocketState(false, false)]
        out SystemLanguage systemLanguage,

        [FriendlyName("internetReachability", "Returns internet reachability status.")]
        [SocketState(false, false)]
        out NetworkReachability internetReachability,

        [FriendlyName("webSecurityEnabled", "Indicates whether Unity's webplayer security model is enabled.")]
        [SocketState(false, false)]
        out bool webSecurityEnabled,

        [FriendlyName("webSecurityHostUrl", "[This appears to be undocumented!]")]
        [SocketState(false, false)]
        out string webSecurityHostUrl,

        [FriendlyName("runInBackground", "Returns the application background play state.")]
        [SocketState(false, false)]
        out bool runInBackground,

        [FriendlyName("targetFrameRate", "Returns the frame rate the game is instructed to use. The value is the ideal frame rate and may not reflect the actual frame rate.")]
        [SocketState(false, false)]
        out int targetFrameRate,

        [FriendlyName("backgroundLoadingPriority", "Returns the priority of background loading thread.")]
        [SocketState(false, false)]
        out ThreadPriority backgroundLoadingPriority,

        [FriendlyName("unityVersion", "The version of the Unity runtime used to play the content.")]
        out string unityVersion
        )
    {
#if (UNITY_3_5 || UNITY_4_6 || UNITY_4_7 || UNITY_5_0 || UNITY_5_1 || UNITY_5_2)
        levelCount      = Application.levelCount;
        loadedLevel     = Application.loadedLevel;
        loadedLevelName = Application.loadedLevelName;
#else
        levelCount      = 0;
        loadedLevel     = 0;
        loadedLevelName = "";
#endif

        isEditor = Application.isEditor;

        // This functionality was depricated in 5.2. You now need to specify a level index, so for
        // general application reporting you can no longer find out if ANY level might be currently loading, which
        // is what this node's intention to report out from this socket was for.
#if (UNITY_3_5 || UNITY_4_6 || UNITY_4_7 || UNITY_5_0 || UNITY_5_1)
        isLoadingLevel = Application.isLoadingLevel;
#endif

        isPlaying     = Application.isPlaying;
        isWebPlayer   = Application.isWebPlayer;
        streamedBytes = Application.streamedBytes;

        platform           = Application.platform;
        dataPath           = Application.dataPath;
        persistentDataPath = Application.persistentDataPath;
        temporaryCachePath = Application.temporaryCachePath;

        srcValue       = Application.srcValue;
        absoluteURL    = Application.absoluteURL;
        unityVersion   = Application.unityVersion;
        systemLanguage = Application.systemLanguage;

        internetReachability = Application.internetReachability;

#if !(UNITY_5_5_OR_NEWER || UNITY_2017)
        webSecurityEnabled = Application.webSecurityEnabled;
        webSecurityHostUrl = Application.webSecurityHostUrl;
#else
        webSecurityEnabled = false;
        webSecurityHostUrl = "";
#endif

        backgroundLoadingPriority = Application.backgroundLoadingPriority;
        runInBackground           = Application.runInBackground;
        targetFrameRate           = Application.targetFrameRate;
    }
 public NetworkStatusRefreshed(NetworkReachability reachability)
 {
     NetworkReachability = reachability;
 }
Exemplo n.º 59
0
 private void Start()
 {
     _reachability = Application.internetReachability;
     Restart();
 }
Exemplo n.º 60
0
 public ConnectivityService()
 {
     _defaultRouteReachability = new NetworkReachability(new IPAddress(0));
     _defaultRouteReachability.Schedule(CFRunLoop.Current, CFRunLoop.ModeDefault);
 }