Beispiel #1
0
 /// <summary>
 /// Method called when a network status changed event is triggered
 /// </summary>
 /// <param name="sender">Object that sent the event</param>
 private void OnNetworkStatusChanged(object sender)
 {
     LogService.Log(MLogLevel.LOG_LEVEL_INFO, "Network status has changed.");
     NetworkService.CheckNetworkChange();
     UpdateConnectionInformation();
     NetworkStatusChanged?.Invoke(this, EventArgs.Empty);
 }
Beispiel #2
0
 private async void OnNetworkStatusChanged(object sender)
 {
     DispatcherProvider provider = new DispatcherProvider();
     await provider.RunOnUIThreadAsync(() => {
         _isOnline = NetworkInterface.GetIsNetworkAvailable();
         NetworkStatusChanged?.Invoke(this, EventArgs.Empty);
     }).ConfigureAwait(false);
 }
Beispiel #3
0
 public CMPNetworkManager(object hostAddressString)
 {
     _hostAddressString = string.Copy(hostAddressString as string);
     _reachability      = new NetworkReachability(_hostAddressString);
     _reachability.SetNotification((NetworkReachabilityFlags
                                    reachabilityFlags) =>
     {
         var networkState = CheckNetworkState(reachabilityFlags);
         NetworkStatusChanged.Invoke(this,
                                     new CMPNetworkEventArgs(networkState));
     });
 }
        private static void NetworkInformation_NetworkStatusChanged(object sender)
        {
            bool newValue = false;

            newValue = NetworkInformation.GetInternetConnectionProfile()?.GetNetworkConnectivityLevel() == NetworkConnectivityLevel.InternetAccess;

            if (newValue == _hasInternet)
            {
                return;
            }
            _hasInternet = newValue;
            NetworkStatusChanged?.Invoke(newValue);
        }
        public override void OnReceive(Context context, Intent intent)
        {
            if (NetworkStatusChanged == null)
            {
                return;
            }

            var networkState = intent.GetIntExtra(KNetworkStatus,
                                                  (int)(NetworkState.Unknown));
            var networkEventArgs = new CMPNetworkEventArgs((NetworkState)networkState);

            if (NetworkStatusChanged != null)
            {
                NetworkStatusChanged.Invoke(this, networkEventArgs);
            }
        }
Beispiel #6
0
    private IEnumerator ConnectionCheckRoutine()
    {
        while (true)
        {
            yield return(new WaitForSeconds(CONN_CHECK_INTERVAL));

            // Check to see if the network status has changed.
            var currentStatus = Application.internetReachability;
            if (_networkStatus != currentStatus)
            {
                Debug.Log($"Network status changed to: {currentStatus.ToString()}");
                _networkStatus = currentStatus;
                NetworkStatusChanged?.Invoke(_networkStatus);
            }

            // if a network is reachable, check to see if it is connected to the net.
            if (_networkStatus != NetworkReachability.NotReachable)
            {
                UnityWebRequest wr = new UnityWebRequest("http://www.google.com");
                yield return(wr.SendWebRequest());

                if (string.IsNullOrEmpty(wr.error))
                {
                    _hasInternetConnection = true;
                }
                else
                {
                    Debug.Log($"Internet Unreachable: {wr.error}");
                    _hasInternetConnection = false;
                }
            }
            else
            {
                Debug.Log($"Internet Unreachable: {_networkStatus.ToString()}");
                _hasInternetConnection = false;
            }
            UpdateStatusText();
        }
    }
 public NetworkStateAdapter()
 {
     NetworkInformation.NetworkStatusChanged += sender => NetworkStatusChanged?.Invoke(sender, EventArgs.Empty);
 }
Beispiel #8
0
 public NetworkStateAdapter()
 {
     NetworkChange.NetworkAddressChanged += (sender, args) => NetworkStatusChanged?.Invoke(sender, args);
 }
Beispiel #9
0
 private void NetworkInformation_NetworkStatusChanged(object sender)
 {
     Network = GetConnectionGeneration();
     NetworkStatusChanged?.Invoke(this);
 }
Beispiel #10
0
 private void OnNetworkStatusChanged(object sender)
 {
     NetworkStatusChanged?.Invoke(sender);
 }
 protected virtual void OnNetworkStatusChanged()
 {
     NetworkStatusChanged?.Invoke(this, EventArgs.Empty);
 }
Beispiel #12
0
 public void OnNetworkStatusChanged()
 {
     NetworkStatusChanged?.Invoke(this);
 }
Beispiel #13
0
 private void NetworkInformation_NetworkStatusChanged(object sender)
 {
     NetworkStatusChanged?.Invoke();
 }