Exemplo n.º 1
0
        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;
        }
Exemplo n.º 2
0
 private void Connect()
 {
     using (Synchronizer.Lock(this)) {
         if (this.m_Sender == null)
         {
             try {
                 this.m_Sender   = new RTPMessageSender(this.m_IPEndPoint, this.m_Model, this.m_Classroom);
                 m_NetworkStatus = new NetworkStatus(ConnectionStatus.Connected, ConnectionProtocolType.RTP, TCPRole.None, 0);
                 if (m_AdvertisedClassroom)
                 {
                     m_NetworkStatus.ClassroomName = "Advertised Classroom (" + m_IPEndPoint.Address.ToString() + ")";
                 }
                 else
                 {
                     m_NetworkStatus.ClassroomName = m_ClassroomName;
                 }
                 m_Model.Network.RegisterNetworkStatusProvider(this, true, m_NetworkStatus);
             } catch (System.Net.Sockets.SocketException se) {
                 //TODO: We need to display a real message box here...
                 MessageBox.Show("Connection failed\n\rMachine must be connected to a network.\r\n"
                                 + "If you repeatedly encounter this error, you may need to restart your machine.\r\n"
                                 + "This is a known bug.  Thanks for your patience.");
                 Debug.WriteLine("Connection failed: " + se.ToString());
             } catch (Exception e) {
                 //TODO: We need to display a real message box here...
                 MessageBox.Show("Connection failed: " + e.ToString());
             }
         }
     }
 }
Exemplo n.º 3
0
        private void Transport_OnTransportStatusChanger(object sender, NetworkStatus e)
        {
            base.Dispatcher.Invoke(() =>
            {
                switch (e)
                {
                case NetworkStatus.Online:
                    networkStatuText.Text       = "ONLINE";
                    networkStatuText.Foreground = new SolidColorBrush(((SolidColorBrush)App.Current.Resources["OWLOSSuccess"]).Color);
                    break;

                case NetworkStatus.Offline:
                    networkStatuText.Text       = "OFFLINE";
                    networkStatuText.Foreground = new SolidColorBrush(((SolidColorBrush)App.Current.Resources["OWLOSWarning"]).Color);
                    break;

                case NetworkStatus.Reconnect:
                    networkStatuText.Text       = "RECONNECT";
                    networkStatuText.Foreground = new SolidColorBrush(((SolidColorBrush)App.Current.Resources["OWLOSPrimary"]).Color);
                    break;

                case NetworkStatus.Erorr:
                    networkStatuText.Text       = "ERROR";
                    networkStatuText.Foreground = new SolidColorBrush(((SolidColorBrush)App.Current.Resources["OWLOSDanger"]).Color);
                    break;
                }

                send_Text.Text = transport.totlaSend.ToString();
                recv_Text.Text = transport.totlaRecv.ToString();
            });
        }
Exemplo n.º 4
0
        private void CheckInternetConnectivity()
        {
            ConnectionProfile InternetConnectionProfile = NetworkInformation.GetInternetConnectionProfile();

            if (InternetConnectionProfile == null)
            {
                _networkStatus = NetworkStatus.NotReachable;
            }
            else
            {
                switch (InternetConnectionProfile.GetNetworkConnectivityLevel())
                {
                case NetworkConnectivityLevel.None:
                case NetworkConnectivityLevel.ConstrainedInternetAccess:
                case NetworkConnectivityLevel.LocalAccess:
                    _networkStatus = NetworkStatus.NotReachable;
                    break;

                case NetworkConnectivityLevel.InternetAccess:
                    if (InternetConnectionProfile.IsWlanConnectionProfile)
                    {
                        _networkStatus = NetworkStatus.ReachableViaWiFiNetwork;
                    }
                    else
                    {
                        _networkStatus = NetworkStatus.ReachableViaCarrierDataNetwork;
                    }
                    break;
                }
            }
        }
Exemplo n.º 5
0
        public string updateStatus()
        {
            string updateStatusValue = "";

            NetworkStatus remoteHostStatus = Reachability.InternetConnectionStatus();

            switch (remoteHostStatus)
            {
            case NetworkStatus.NotReachable:
                //Debug.WriteLine ("Not Reachable Appdelegate");
                updateStatusValue = "Not Rechable";
                break;

            case NetworkStatus.ReachableViaCarrierDataNetwork:
                //Debug.WriteLine ("Reachable Appdelegate");
                updateStatusValue = "Available";

                break;

            case NetworkStatus.ReachableViaWiFiNetwork:
                //Debug.WriteLine ("Reachable Appdelegate");
                updateStatusValue = "Available";

                break;
            }
            return(updateStatusValue);
        }
Exemplo n.º 6
0
 public ConnectionInfo(string hostname, IPAddress ipAddress, NetworkCredential credentials)
 {
     _hostname    = hostname;
     _ipAddress   = ipAddress;
     _credentials = credentials;
     _status      = NetworkStatus.Unknown;
 }
Exemplo n.º 7
0
    void OnPeriodicalUpdate()
    {
        if (networkManager == null)
        {
            return;
        }


        txtIp.text = networkManager.GetIp().ToString();
        NetworkStatus networkStatus = networkManager.GetStatus();

        startClient.interactable = networkManager != null && networkStatus.networkType == NetworkType.NONE;
        startServer.interactable = networkManager != null && networkStatus.networkType == NetworkType.NONE;

        txtStatus.text = $"{networkStatus.networkType.ToString()}: \tCONNECTED: {networkStatus.connected.ToString()}";

        txtMessage.text = JsonUtility.ToJson(networkManager.GetMessage());

        if (networkStatus.connected)
        {
            switch (networkStatus.networkType)
            {
            case NetworkType.CLIENT:
                SceneManager.LoadScene("Level1", LoadSceneMode.Single);
                break;

            case NetworkType.SERVER:
                SceneManager.LoadScene("WyjczyEtap", LoadSceneMode.Single);
                break;
            }
        }
    }
Exemplo n.º 8
0
        private void OnTransportStatusChanger(object sender, NetworkStatus e)
        {
            base.Dispatcher.Invoke(() =>
            {
                OWLOSTransport transport = sender as OWLOSTransport;


                switch (e)
                {
                case NetworkStatus.Online:
                    Rotate(angel);
                    break;

                case NetworkStatus.Offline:
                    Rotate(90 + angel);
                    break;

                case NetworkStatus.Reconnect:
                    Rotate(180 + angel);
                    break;

                case NetworkStatus.Erorr:
                    Rotate(270 + angel);
                    break;
                }

                this.UpdateLayout();

                if (relationLine?.curveLine != null)
                {
                    relationLine?.UpdatePositions();
                }
            });
        }
Exemplo n.º 9
0
        public NetworkReachability()
        {
            //TODO: need a better way to implement this
            if(_networkBroadcastReceiver == null)
            {
                var context = Application.Context;
                _networkBroadcastReceiver = new NetworkStatusChangeBroadcastReceiver();
                _networkBroadcastReceiver.ConnectionStatusChanged += NetworkStatusChanged;
                Application.Context.RegisterReceiver(_networkBroadcastReceiver, new IntentFilter(ConnectivityManager.ConnectivityAction));

                //update the network status for the first time
                var connectivityManager = (ConnectivityManager)context.GetSystemService(Context.ConnectivityService);
                var activeConnection = connectivityManager.ActiveNetworkInfo;
                var connectionStatus = NetworkStatus.NotReachable;

                if ((activeConnection != null) && activeConnection.IsConnected)
                {
                    if (activeConnection.Type == ConnectivityType.Wifi)
                    {
                        connectionStatus = NetworkStatus.ReachableViaWiFiNetwork;
                    }
                    else
                    {
                        connectionStatus = NetworkStatus.ReachableViaCarrierDataNetwork;
                    }
                }

                this._networkStatus = connectionStatus;
            }
        }
Exemplo n.º 10
0
 void UpdateStatus()
 {
     remoteHostStatus = Reachability.RemoteHostStatus();
     internetStatus   = Reachability.InternetConnectionStatus();
     localWifiStatus  = Reachability.LocalWifiConnectionStatus();
     tableView.ReloadData();
 }
Exemplo n.º 11
0
        void UpdateConnected(bool triggerChange = true)
        {
            var remoteHostStatus = Reachability.RemoteHostStatus();
            var internetStatus   = Reachability.InternetConnectionStatus();
            var localWifiStatus  = Reachability.LocalWifiConnectionStatus();

            var previouslyConnected = isConnected;

            isConnected = (internetStatus == NetworkStatus.ReachableViaCarrierDataNetwork ||
                           internetStatus == NetworkStatus.ReachableViaWiFiNetwork) ||
                          (localWifiStatus == NetworkStatus.ReachableViaCarrierDataNetwork ||
                           localWifiStatus == NetworkStatus.ReachableViaWiFiNetwork) ||
                          (remoteHostStatus == NetworkStatus.ReachableViaCarrierDataNetwork ||
                           remoteHostStatus == NetworkStatus.ReachableViaWiFiNetwork);

            if (triggerChange && (previouslyConnected != isConnected || previousInternetStatus != internetStatus))
            {
                OnConnectivityChanged(new ConnectivityChangedEventArgs {
                    IsConnected = isConnected
                });
            }
            previousInternetStatus = internetStatus;

            // CheckNotificationRegister();
        }
Exemplo n.º 12
0
        public override void StartTracking()
        {
            base.StartTracking();

            _currentConnectionStatus          = Reachability.InternetConnectionStatus();
            Reachability.ReachabilityChanged += OnReachabilityChanged;
        }
Exemplo n.º 13
0
        public void RetrieveNetworkStatus()
        {
            try
            {
                ConnectionProfile connectionProfile = Windows.Networking.Connectivity.NetworkInformation.GetInternetConnectionProfile();
                if (connectionProfile != null)
                {
                    switch (connectionProfile.NetworkAdapter.IanaInterfaceType)
                    {
                    case 71:
                    case 6:
                        this.NetworkStatus = NetworkStatus.WiFi;
                        break;

                    default:
                        if (connectionProfile.GetConnectionCost().ApproachingDataLimit || connectionProfile.GetConnectionCost().OverDataLimit || connectionProfile.GetConnectionCost().Roaming)
                        {
                            this.NetworkStatus = NetworkStatus.MobileRestricted;
                            break;
                        }
                        this.NetworkStatus = NetworkStatus.MobileUnrestricted;
                        break;
                    }
                }
                else
                {
                    this.NetworkStatus = NetworkStatus.None;
                }
            }
            catch (Exception ex)
            {
                Logger.Instance.Error("Cannot retrieve network status", ex);
            }
        }
Exemplo n.º 14
0
        public static void WifiDialog(string message, Action callback)
        {
            NetworkStatus remoteHostStatus = Reachability.RemoteHostStatus();

            if (remoteHostStatus == NetworkStatus.ReachableViaWiFiNetwork)
            {
                callback();
            }
            else if (remoteHostStatus == NetworkStatus.ReachableViaCarrierDataNetwork)
            {
                UIAlertView alert = new UIAlertView("No WiFi Connection Found", message, null, "No", "Yes");
                alert.Clicked += (object sender, UIButtonEventArgs e) => {
                    if (e.ButtonIndex == 0)
                    {
                        return;
                    }
                    else
                    {
                        callback();
                    }
                };
                alert.Show();
            }
            else
            {
                new UIAlertView("No Data Connection", "We were unable to detect a network connection and are unable to log you in.", null, "Ok").Show();
            }
        }
Exemplo n.º 15
0
		void UpdateStatus ()
		{
			remoteHostStatus = Reachability.RemoteHostStatus ();
			internetStatus = Reachability.InternetConnectionStatus ();
			localWifiStatus = Reachability.LocalWifiConnectionStatus ();
			tableView.ReloadData ();
		}
Exemplo n.º 16
0
        public override async Task NetworkStatusChanged(NetworkStatus newStatus)
        {
            if ((CurrentNetworkStatus == NetworkStatus.NotReachable) && (newStatus != NetworkStatus.NotReachable))
            {
                var restored = await RestService.Instance.CheckIfConnectionRestored();

                if (!restored)
                {
                    return;
                }
            }

            var current = CurrentNetworkStatus;
            await base.NetworkStatusChanged(newStatus);

            if (current != newStatus)
            {
                await accountViewModel.NetworkStatusChanged(newStatus);

                await libraryViewModel.NetworkStatusChanged(newStatus);

                await mediaContentViewModel.NetworkStatusChanged(newStatus);

                await notificationsViewModel.NetworkStatusChanged(newStatus);

                await queueViewModel.NetworkStatusChanged(newStatus);

                if ((current != NetworkStatus.NotReachable) && (newStatus == NetworkStatus.NotReachable))
                {
                    libraryViewModel.SelectedView = (int)LibraryViewMode.Device;
                    SelectedItem = CloudItem.Library;
                }
            }
        }
Exemplo n.º 17
0
 //refer this http://stackoverflow.com/questions/16523447/how-to-detect-if-windows-8-device-is-on-wifi-lan-or-3g-internet-connection
 private void CheckInternetConnectivity()
 {
     ConnectionProfile InternetConnectionProfile = NetworkInformation.GetInternetConnectionProfile();
     if (InternetConnectionProfile == null)
         _networkStatus = NetworkStatus.NotReachable;
     else
     {
         switch (InternetConnectionProfile.GetNetworkConnectivityLevel())
         {
             case NetworkConnectivityLevel.None:
             case NetworkConnectivityLevel.ConstrainedInternetAccess:
             case NetworkConnectivityLevel.LocalAccess:
                 _networkStatus = NetworkStatus.NotReachable;
                 break;
             case NetworkConnectivityLevel.InternetAccess:
                 {
                     var interfaceType = InternetConnectionProfile.NetworkAdapter.IanaInterfaceType;
                     
                     // 71 is WiFi & 6 is Ethernet(LAN)
                     if (interfaceType == 71 || interfaceType == 6)
                     {
                         _networkStatus = NetworkStatus.ReachableViaWiFiNetwork;
                     }
                     // 243 & 244 is 3G/Mobile
                     else if (interfaceType == 243 || interfaceType == 244)
                     {
                         _networkStatus = NetworkStatus.ReachableViaCarrierDataNetwork;
                     }
                 }
                 break;
         }
     }
 }
Exemplo n.º 18
0
        public TCPClient(IPEndPoint remoteEP, ParticipantModel participant, NetworkModel network, Guid serverID)
        {
            m_Connected = false;
            m_Network = network;
            m_Participant = participant;
            m_LastMsgReceived = DateTime.MaxValue;
            m_ServerId = serverID;
            m_ClientTimeout = TimeSpan.FromMilliseconds(TCP_HEARTBEAT_TIMEOUT_DEFAULT_MS);
            this.m_RemoteEP = remoteEP;
            m_Socket = null;
            m_ServerParticipant = null;
            m_ReceiveQueue = new Queue();
            this.m_Encoder = new Chunk.ChunkEncoder();
            m_NetworkStatus = new NetworkStatus(ConnectionStatus.Disconnected, ConnectionProtocolType.TCP, TCPRole.Client, 0);
            this.m_Network.RegisterNetworkStatusProvider(this, true, m_NetworkStatus);

            //Find out if client-side bridging is enabled
            m_BridgeEnabled = false;
            string enableBridge = System.Configuration.ConfigurationManager.AppSettings[this.GetType().ToString() + ".EnableBridge"];
            if (enableBridge != null) {
                bool enable = false;
                if (bool.TryParse(enableBridge, out enable)) {
                    Trace.WriteLine("Unicast to Multicast Bridge enabled=" + enable.ToString(), this.GetType().ToString());
                    m_BridgeEnabled = enable;
                }
            }
        }
Exemplo n.º 19
0
        public void PauseServer()
        {
            if (true == m_isActive)
            {
                m_isActive = false;
                if (true == m_useLocalIP)
                {
                    m_PStat = ProcessStatus.Pause;
                }
                m_NStat = NetworkStatus.Pause;
            }
            else
            {
                m_isActive = true;
                if (true == m_useLocalIP)
                {
                    m_PStat = ProcessStatus.Lost;
                }
                m_NStat = NetworkStatus.Timeout;

                if (null != m_Thread && true == m_Thread.IsAlive)
                {
                    return;
                }
            }

            m_Thread = new Thread(new ThreadStart(CheckServer));
            m_Thread.Start();
        }
Exemplo n.º 20
0
        /// <summary>
        /// Checks internet connection status
        /// </summary>
        /// <returns></returns>
        public static NetworkStatus InternetConnectionStatus()
        {
            NetworkStatus status = NetworkStatus.NotReachable;

            NetworkReachabilityFlags flags;
            bool defaultNetworkAvailable = IsNetworkAvailable(out flags);

            // If the connection is reachable and no connection is required, then assume it's WiFi
            if (defaultNetworkAvailable)
            {
                status = NetworkStatus.ReachableViaWiFiNetwork;
            }

            // If the connection is on-demand or on-traffic and no user intervention
            // is required, then assume WiFi.
            if (((flags & NetworkReachabilityFlags.ConnectionOnDemand) != 0 ||
                 (flags & NetworkReachabilityFlags.ConnectionOnTraffic) != 0) &&
                (flags & NetworkReachabilityFlags.InterventionRequired) == 0)
            {
                status = NetworkStatus.ReachableViaWiFiNetwork;
            }

            // If it's a WWAN connection..
            if ((flags & NetworkReachabilityFlags.IsWWAN) != 0)
            {
                status = NetworkStatus.ReachableViaCarrierDataNetwork;
            }

            return(status);
        }
Exemplo n.º 21
0
    private IEnumerator CheckVersion()
    {
        // /repos/{owner}/{repo}/releases
        var web = UnityWebRequest.Get("https://api.github.com/repos/GlowPuff/ImperialCommander/releases/latest");

        yield return(web.SendWebRequest());

        if (web.result == UnityWebRequest.Result.ConnectionError)
        {
            Debug.Log("network error");
            networkStatus = NetworkStatus.Error;
            busyIconTF.GetComponent <Image>().color = new Color(1, 0, 0);
            gitHubResponse = null;
        }
        else
        {
            //parse JSON response
            gitHubResponse = JsonConvert.DeserializeObject <GitHubResponse>(web.downloadHandler.text);

            if (gitHubResponse.tag_name == DataStore.appVersion)
            {
                networkStatus = NetworkStatus.UpToDate;
                busyIconTF.GetComponent <Image>().color = new Color(0, 1, 0);
            }
            else
            {
                networkStatus = NetworkStatus.WrongVersion;
                busyIconTF.GetComponent <Image>().color = new Color(1, 0.5586207f, 0);
            }
        }

        yield return(null);
    }
Exemplo n.º 22
0
        /// <summary>
        /// 测试网络状态
        /// </summary>
        /// <returns></returns>
        public static NetworkStatus Fun_IsNetworkAlive()
        {
            int NETWORK_ALIVE_LAN = 0;
            int NETWORK_ALIVE_WAN = 2;
            int NETWORK_ALIVE_AOL = 4;

            NetworkStatus status = NetworkStatus.无网络;
            int           flags;            //上网方式
            bool          m_bOnline = true; //是否在线

            m_bOnline = IsNetworkAlive(out flags);
            if (m_bOnline)//在线
            {
                if ((flags & NETWORK_ALIVE_LAN) == NETWORK_ALIVE_LAN)
                {
                    status = NetworkStatus.拨号上网;
                }
                if ((flags & NETWORK_ALIVE_WAN) == NETWORK_ALIVE_WAN)
                {
                    status = NetworkStatus.局域网;
                }
                if ((flags & NETWORK_ALIVE_AOL) == NETWORK_ALIVE_AOL)
                {
                    //"在线:NETWORK_ALIVE_AOL\n"; 不知道这是什么意思,暂时用这个代替
                    status = NetworkStatus.拨号上网;
                }
            }
            else
            {
                status = NetworkStatus.无网络;
            }

            return(status);
        }
Exemplo n.º 23
0
        /// <summary>
        /// Determines whether the user is on wifi or not
        /// </summary>
        /// <returns><c>true</c>, if internet conection is on wifi, <c>false</c> otherwise.</returns>
        public static bool ValidWifiConectionExists()
        {
            var           device        = DependencyService.Get <IDevice>();
            NetworkStatus networkStatus = device.Network.InternetConnectionStatus();

            return(networkStatus == NetworkStatus.ReachableViaWiFiNetwork);
        }
Exemplo n.º 24
0
 internal void OnNetworkReachabilityChanged(NetworkStatus status)
 {
     EventHandler<NetworkStatusEventArgs> handler = mNetworkReachabilityChanged;
     if (handler != null)
     {
         handler(null, new NetworkStatusEventArgs(status));
     }
 }
Exemplo n.º 25
0
        public WalletStatus(uint walletHeight, BlockchainStatus blockchainStatus, NetworkStatus networkStatus)
        {
            this.WalletHeight = walletHeight;

            this.BlockchainStatus = blockchainStatus;

            this.NetworkStatus = networkStatus;
        }
Exemplo n.º 26
0
        /// <summary>
        /// Determines whether the user has a valid internet connection available.
        /// </summary>
        /// <returns><c>true</c>, if internet conection was valided, <c>false</c> otherwise.</returns>
        public static bool ValidInternetConectionExists()
        {
            var           device        = DependencyService.Get <IDevice>();
            NetworkStatus networkStatus = device.Network.InternetConnectionStatus();

            return(networkStatus !=
                   NetworkStatus.NotReachable);
        }
Exemplo n.º 27
0
 private void NetworkStatusChanged(object sender, NetworkStatus e)
 {
     this._networkStatus = e;
     if (NetworkReachabilityChanged != null)
     {
         NetworkReachabilityChanged(this, new NetworkStatusEventArgs(e));
     }
 }
        async void BindDropDowns()
        {
            btnFilter.IsHitTestVisible = false;
            string url = "http://api.faitango.it/filter.php?";

            try
            {
                if (NetworkStatus.CheckInternetAccess())
                {
                    wsFilterDropDownsModel _result = new wsFilterDropDownsModel();
                    _result = await Common.CommonClass.GetFiltersDropDowns(url);

                    if (_result != null)
                    {
                        List <Province> lstProvince = new List <Models.Province>();
                        lstProvince = _result.province.ToList();
                        lstProvince.Insert(0, new Models.Province {
                            codes = "0", name = "Select province"
                        });

                        cmbProvince.ItemsSource       = lstProvince;
                        cmbProvince.DisplayMemberPath = "name";
                        cmbProvince.SelectedValuePath = "codes";

                        cmbProvince.SelectedIndex = 0;

                        List <Region> lstRegion = new List <Models.Region>();
                        lstRegion = _result.region.ToList();
                        lstRegion.Insert(0, new Models.Region  {
                            codes = "0", name = "Select region"
                        });

                        cmbRegion.ItemsSource       = lstRegion;
                        cmbRegion.DisplayMemberPath = "name";
                        cmbRegion.SelectedValuePath = "codes";

                        cmbRegion.SelectedIndex = 0;
                    }
                    else
                    {
                        MessageDialog msgbox = new MessageDialog("Server error.");
                        await msgbox.ShowAsync();
                    }
                }
                else
                {
                    MessageDialog msgbox = new MessageDialog("Internet connection is not available.");
                    await msgbox.ShowAsync();
                }
            }
            catch
            {
            }
            finally
            {
                btnFilter.IsHitTestVisible = true;
            }
        }
Exemplo n.º 29
0
        public override async Task NetworkStatusChanged(NetworkStatus newStatus)
        {
            if (newStatus != NetworkStatus.NotReachable)
            {
                await Init();
            }

            await base.NetworkStatusChanged(newStatus);
        }
 public ActivityStartViewController()
 {
     _navigationService              = ServiceLocator.Current.GetInstance <INavigationService>();
     _assignmentVm                   = ServiceLocator.Current.GetInstance <AssignmentVm>();
     _assignmentVm.RecordingChanged += OnRecordingChanged;
     _assignmentVm.TimerChanged     += OnTimerChanged;
     _networkStatus                  = Reachability.InternetConnectionStatus();
     BuildInterface();
 }
Exemplo n.º 31
0
        /// <summary>
        /// This method processes queued web requests and user callbacks.
        /// </summary>
        void ProcessRequests()
        {
            // 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");
                }
            }

            //trigger network updates if status has changed
            var nr = ServiceFactory.Instance.GetService <INetworkReachability>() as Amazon.Util.Internal.PlatformServices.NetworkReachability;

            if (_currentNetworkStatus != nr.NetworkStatus)
            {
                _currentNetworkStatus = nr.NetworkStatus;
                nr.OnNetworkReachabilityChanged(_currentNetworkStatus);
            }
        }
Exemplo n.º 32
0
        internal void OnNetworkReachabilityChanged(NetworkStatus status)
        {
            EventHandler <NetworkStatusEventArgs> handler = mNetworkReachabilityChanged;

            if (handler != null)
            {
                handler(null, new NetworkStatusEventArgs(status));
            }
        }
        private TreeViewWithIcons createTreeViewItem(String id, String name, NetworkStatus status)
        {
            TreeViewWithIcons item = new TreeViewWithIcons();

            item.Tag        = id;
            item.HeaderText = name;
            item.Icon       = CreateImage(getImageForStatus(status));
            return(item);
        }
Exemplo n.º 34
0
        /// <summary> Use only on server. </summary>
        public static void    SendChatMessageToPlayer(Player player, string msg)
        {
            if (!NetworkStatus.IsServerStarted())
            {
                return;
            }

            SendChatMessageToPlayer(player, msg, singleton.serverChatNick);
        }
        public override async Task NetworkStatusChanged(NetworkStatus newStatus)
        {
            if ((CurrentNetworkStatus == NetworkStatus.NotReachable) && (newStatus != NetworkStatus.NotReachable))
            {
                await refresh(false);
            }

            await base.NetworkStatusChanged(newStatus);
        }
Exemplo n.º 36
0
        private NetworkStatus NetworkStatusHelper(NetworkReachabilityFlags flags)
        {
            if (!IsReachableWithoutRequiringConnection(flags))
                _networkStatus = NetworkStatus.NotReachable;
            else if ((flags & NetworkReachabilityFlags.IsWWAN) != 0)
                _networkStatus = NetworkStatus.ReachableViaCarrierDataNetwork;
            else
                _networkStatus = NetworkStatus.ReachableViaWiFiNetwork;

            return _networkStatus;
        }
		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;
		}
Exemplo n.º 38
0
 private async void CheckConnection()
 {
     try
     {
         await Dispatcher.RunAsync(CoreDispatcherPriority.Normal, () =>
         {
             _status = NetworkInformation.GetInternetConnectionProfile() != null
                 ? NetworkStatus.Connected
                 : NetworkStatus.NoConnection;
         });
     }
     catch
     {
         _status = NetworkStatus.Unknown;
     }
 }
        void UpdateStatus ()
        {
            counter++;
            remoteHostStatus = Reachability.RemoteHostStatus ();
            internetStatus = Reachability.InternetConnectionStatus ();
            localWifiStatus = Reachability.LocalWifiConnectionStatus ();

            if (counter == 1)
            {
                currentInternetStatus = internetStatus;
                return;
            }

            if (currentInternetStatus != internetStatus)
            {
                MakeSound(internetStatus == NetworkStatus.ReachableViaWiFiNetwork || internetStatus == NetworkStatus.ReachableViaCarrierDataNetwork);
                currentInternetStatus = internetStatus;
            }

        }
        // This constructor will be called while loading the data from a XML file
        public Device(int deviceID, int parentID, string domain, string ipaddress, String deviceName, double latitude, double longitude, bool disabled, NetworkStatus currentStatus)
        {
            this.DeviceId = deviceID == -1 ? deviceIDSeq : deviceID;
            this.ParentID = parentID;
            this.DeviceName = deviceName;
            this.MapCoOrdinate = new Location(latitude, longitude);
            this.Disabled = disabled;
            this.CurrentStatus = currentStatus;
            
            this.DomainName = domain ;
            IPAddress ip;
            if (IPAddress.TryParse(ipaddress, out ip))
            {
                this.Ipaddress = ip;
            }
            else
            {
                this.Ipaddress = null; 
            }

            validateIDSeq(deviceIDSeq);
        }
Exemplo n.º 41
0
 private void CheckInternetConnectivity()
 {
     ConnectionProfile InternetConnectionProfile = NetworkInformation.GetInternetConnectionProfile();
     if (InternetConnectionProfile == null)
         _networkStatus = NetworkStatus.NotReachable;
     else
     {
         switch (InternetConnectionProfile.GetNetworkConnectivityLevel())
         {
             case NetworkConnectivityLevel.None:
             case NetworkConnectivityLevel.ConstrainedInternetAccess:
             case NetworkConnectivityLevel.LocalAccess:
                 _networkStatus = NetworkStatus.NotReachable;
                 break;
             case NetworkConnectivityLevel.InternetAccess:
                 if (InternetConnectionProfile.IsWlanConnectionProfile)
                     _networkStatus = NetworkStatus.ReachableViaWiFiNetwork;
                 else
                     _networkStatus = NetworkStatus.ReachableViaCarrierDataNetwork;
                 break;
         }
     }
 }
        /// <summary>
        /// Adds a pin to the specified location in the map with specified status
        /// </summary>
        /// <param name="location"></param>
        /// <param name="status"></param>
        private void addPushpinToMap(Location location, NetworkStatus status, string title)
        {

            Image image = new Image();
            //image.Height = 150;
            //Define the URI location of the image
            BitmapImage myBitmapImage = new BitmapImage();
            myBitmapImage.BeginInit();

            if (status == NetworkStatus.ONLINE)
                myBitmapImage.UriSource = new Uri(Directory.GetCurrentDirectory() + "\\image\\pin_green.png");
            else
                myBitmapImage.UriSource = new Uri(Directory.GetCurrentDirectory() + "\\image\\pin_red.png");

            // To save significant application memory, set the DecodePixelWidth or  
            // DecodePixelHeight of the BitmapImage value of the image source to the desired 
            // height or width of the rendered image. If you don't do this, the application will 
            // cache the image as though it were rendered as its normal size rather then just 
            // the size that is displayed.
            // Note: In order to preserve aspect ratio, set DecodePixelWidth
            // or DecodePixelHeight but not both.
            //Define the image display properties
            //myBitmapImage.DecodePixelHeight = 150;
            myBitmapImage.EndInit();
            image.Source = myBitmapImage;
            image.Opacity = 1.0;
            image.Stretch = System.Windows.Media.Stretch.None;
            ToolTip tooltip = new System.Windows.Controls.ToolTip();
            tooltip.FontSize = 14;
            tooltip.Content = title;
            image.ToolTip = tooltip;


            //Add the image to the defined map layer
            imageLayer.AddChild(image, location, PositionOrigin.BottomLeft);

        }
 private TreeViewWithIcons createTreeViewItem(String id, String name, NetworkStatus status)
 {
     TreeViewWithIcons item = new TreeViewWithIcons();
     item.Tag = id;
     item.HeaderText = name;
     item.Icon = CreateImage(getImageForStatus(status));
     return item;
 }
 /// <summary>
 /// Updates the network status
 /// </summary>
 /// <description>
 /// Check for network errors/connectivity
 /// </description>
 /// <see cref="ProScanMobile.Reachability"/>
 private void updateNetworkStatus()
 {
     _remoteHostStatus = Reachability.RemoteHostStatus ();
     _internetStatus = Reachability.InternetConnectionStatus ();
 }
 public NetworkEventArgs(NetworkStatus status)
 {
     Status = status;
 }
Exemplo n.º 46
0
 /// <summary>
 /// Initializes a new instance of the <see cref="Network"/> class.
 /// </summary>
 public Network()
 {
     _networkStatus = InternetConnectionStatus();
 }
 // called from xml parser while loading the data from XML file
 public static void loadDeviceFromXML(int deviceID, int parentID, string domain, string ipaddress, String deviceName, double latitude, double longitude, bool disabled, NetworkStatus currentStatus)
 {
     Device devObj = new Device(deviceID, parentID, domain, ipaddress, deviceName, latitude, longitude, disabled, currentStatus );
     deviceList.Add(devObj);
 }
Exemplo n.º 48
0
		void UpdateStatus (object sender, EventArgs e)
		{
			remoteHostStatus = Reachability.RemoteHostStatus ();
			internetStatus = Reachability.InternetConnectionStatus ();
			localWifiStatus = Reachability.LocalWifiConnectionStatus ();
			TableView.ReloadData ();
		}
 public void Register()
 {
     m_NetworkStatus = new NetworkStatus(ConnectionStatus.Connected, ConnectionProtocolType.CXPCapability, TCPRole.None, 0);
     m_NetworkStatus.ClassroomName = "ConferenceXP Capability";
     m_Model.Network.RegisterNetworkStatusProvider(this, true, m_NetworkStatus);
 }
Exemplo n.º 50
0
 private void OnNetworkStatusChanged(NetworkStatus status)
 {
     if (NetworkStatusChanged != null)
         NetworkStatusChanged(status);
 }
Exemplo n.º 51
0
 public NetworkAwarenessAttribute(NetworkStatus mode)
 {
     Mode = mode;
 }
		void updateStatus ()
		{
			internetStatus = Reachability.InternetConnectionStatus ();
		}
        private string getImageForStatus(NetworkStatus status)
        {
            switch (status)
            {
                case NetworkStatus.ONLINE:
                    return Directory.GetCurrentDirectory() + "\\image\\greendot.jpg";
                case NetworkStatus.OFFLINE:
                    return Directory.GetCurrentDirectory() + "\\image\\reddot.png";
                default:
                    return Directory.GetCurrentDirectory() + "\\image\\greydot.jpg";
            }

        }
Exemplo n.º 54
0
 private void NetworkStatusChanged(object sender, NetworkStatus e)
 {
     this._networkStatus = e;
     if (NetworkReachabilityChanged != null)
         NetworkReachabilityChanged(this, new NetworkStatusEventArgs(e));
 }
Exemplo n.º 55
0
 private void Connect()
 {
     using(Synchronizer.Lock(this)) {
         if(this.m_Sender == null) {
             try {
                 this.m_Sender = new RTPMessageSender(this.m_IPEndPoint, this.m_Model, this.m_Classroom);
                 m_NetworkStatus = new NetworkStatus(ConnectionStatus.Connected, ConnectionProtocolType.RTP, TCPRole.None, 0);
                 if (m_AdvertisedClassroom) {
                     m_NetworkStatus.ClassroomName = "Advertised Classroom (" + m_IPEndPoint.Address.ToString() + ")";
                 }
                 else {
                     m_NetworkStatus.ClassroomName = m_ClassroomName;
                 }
                 m_Model.Network.RegisterNetworkStatusProvider(this, true, m_NetworkStatus);
             } catch (System.Net.Sockets.SocketException se) {
                 //TODO: We need to display a real message box here...
                 MessageBox.Show("Connection failed\n\rMachine must be connected to a network.\r\n"
                     + "If you repeatedly encounter this error, you may need to restart your machine.\r\n"
                     + "This is a known bug.  Thanks for your patience.");
                 Debug.WriteLine("Connection failed: " + se.ToString());
             } catch (Exception e) {
                 //TODO: We need to display a real message box here...
                 MessageBox.Show("Connection failed: " + e.ToString());
             }
         }
     }
 }
Exemplo n.º 56
0
 /// <summary>
 /// Create a new instance of the Network class.
 /// </summary>
 /// <param name="id">The Id of the network.</param>
 /// <param name="name">The name of the network.</param>
 /// <param name="status">The status of the network.</param>
 internal Network(string id, string name, NetworkStatus status)
 {
     this.Id = id;
     this.Name = name;
     this.Status = status;
 }
Exemplo n.º 57
0
        private static void OnNetworkStatusChanged(NetworkStatus status)
        {
            if (status == NetworkStatus.Disconnected)
            {
                _request.AESIV = _aesIV;
                _request.AESKey = _aesKey;
                _request.EnableSend = false;
            }

            if (NetworkStatusChanged != null)
                NetworkStatusChanged(status);
        }
Exemplo n.º 58
0
 public NetworkEventArgs(int id, NetworkStatus status, string extendedInfo)
 {
     ID = id;
     Status = status;
     ExtendedInfo = extendedInfo;
 }
 public NetworkStatusEventArgs(NetworkStatus status)
 {
     this.Status = status;
 }
Exemplo n.º 60
0
 public void AddStatus(NetworkStatus status)
 {
     _SendingQueue.Add(new SyncStatus() { Status = status });
 }