コード例 #1
0
ファイル: NetworkHelper.cs プロジェクト: hmrg-grmh/meganz-uwp
 /// <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);
 }
コード例 #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);
 }
コード例 #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));
     });
 }
コード例 #4
0
        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);
        }
コード例 #5
0
        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);
            }
        }
コード例 #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);
 }
コード例 #8
0
 public NetworkStateAdapter()
 {
     NetworkChange.NetworkAddressChanged += (sender, args) => NetworkStatusChanged?.Invoke(sender, args);
 }
コード例 #9
0
 private void NetworkInformation_NetworkStatusChanged(object sender)
 {
     Network = GetConnectionGeneration();
     NetworkStatusChanged?.Invoke(this);
 }
コード例 #10
0
 private void OnNetworkStatusChanged(object sender)
 {
     NetworkStatusChanged?.Invoke(sender);
 }
コード例 #11
0
 protected virtual void OnNetworkStatusChanged()
 {
     NetworkStatusChanged?.Invoke(this, EventArgs.Empty);
 }
コード例 #12
0
 public void OnNetworkStatusChanged()
 {
     NetworkStatusChanged?.Invoke(this);
 }
コード例 #13
0
ファイル: Network.cs プロジェクト: viewsat/GMaster
 private void NetworkInformation_NetworkStatusChanged(object sender)
 {
     NetworkStatusChanged?.Invoke();
 }