/// <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); }
private async void OnNetworkStatusChanged(object sender) { DispatcherProvider provider = new DispatcherProvider(); await provider.RunOnUIThreadAsync(() => { _isOnline = NetworkInterface.GetIsNetworkAvailable(); NetworkStatusChanged?.Invoke(this, EventArgs.Empty); }).ConfigureAwait(false); }
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); } }
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); }
public NetworkStateAdapter() { NetworkChange.NetworkAddressChanged += (sender, args) => NetworkStatusChanged?.Invoke(sender, args); }
private void NetworkInformation_NetworkStatusChanged(object sender) { Network = GetConnectionGeneration(); NetworkStatusChanged?.Invoke(this); }
private void OnNetworkStatusChanged(object sender) { NetworkStatusChanged?.Invoke(sender); }
protected virtual void OnNetworkStatusChanged() { NetworkStatusChanged?.Invoke(this, EventArgs.Empty); }
public void OnNetworkStatusChanged() { NetworkStatusChanged?.Invoke(this); }
private void NetworkInformation_NetworkStatusChanged(object sender) { NetworkStatusChanged?.Invoke(); }