private void UpdateConnected(bool triggerChange = true) { var remoteHostStatus = Reachability.RemoteHostStatus(); var internetStatus = Reachability.InternetConnectionStatus(); var previouslyConnected = isConnected; isConnected = (internetStatus == NetworkStatus.ReachableViaCarrierDataNetwork || internetStatus == NetworkStatus.ReachableViaWiFiNetwork) || (remoteHostStatus == NetworkStatus.ReachableViaCarrierDataNetwork || remoteHostStatus == NetworkStatus.ReachableViaWiFiNetwork); if (triggerChange) { if (previouslyConnected != isConnected || previousInternetStatus != internetStatus) { OnConnectivityChanged(new ConnectivityChangedEventArgs { IsConnected = isConnected }); } var connectionTypes = this.ConnectionTypes.ToArray(); OnConnectivityTypeChanged(new ConnectivityTypeChangedEventArgs { IsConnected = isConnected, ConnectionTypes = connectionTypes }); } previousInternetStatus = internetStatus; }
private void UpdateConnected(bool triggerChange = true) { var remoteHostStatus = Reachability.RemoteHostStatus(); var internetStatus = Reachability.InternetConnectionStatus(); var localWifiStatus = Reachability.LocalWifiConnectionStatus(); var previouslyConnected = isConnected; isConnected = internetStatus == NetworkStatus.ReachableViaWiFiNetwork || localWifiStatus == NetworkStatus.ReachableViaWiFiNetwork || remoteHostStatus == NetworkStatus.ReachableViaWiFiNetwork; if (triggerChange && (previouslyConnected != isConnected || previousInternetStatus != internetStatus)) { OnConnectivityChanged(new ConnectivityChangedEventArgs { IsConnected = isConnected }); } previousInternetStatus = internetStatus; }