private IEnumerator MonitorNetworkConnectivity(NetworkConnectivitySettings _settings)
        {
            NetworkConnectivitySettings.AndroidSettings _androidSettings = _settings.Android;

            string _pingAddress		= _settings.IPAddress;
            int _maxRetryCount		= _androidSettings.MaxRetryCount;
            float _dt				= _androidSettings.TimeGapBetweenPolling;
            float _timeOutPeriod	= _androidSettings.TimeOutPeriod;
            bool _connectedToNw		= IsConnected;

            while (true)
            {
                bool _nowConnected	= false;

                for (int _rIter = 0; _rIter < _maxRetryCount; _rIter++)
                {
                    Ping _ping			= new Ping(_pingAddress);
                    float  _elapsedTime	= 0f;

                    // Ping test
                    while (!_ping.isDone && _elapsedTime < _timeOutPeriod)
                    {
                        _elapsedTime	+= Time.deltaTime;

                        // Wait until next frame
                        yield return null;
                    }

                    // Ping request complted within timeout period, so we are connected to network
                    if (_ping.isDone && (_ping.time != -1) && _elapsedTime < _timeOutPeriod)
                    {
                        _nowConnected	= true;
                        break;
                    }
                }

                // Notify Manager about state change
                if (!_connectedToNw)
                {
                    if (_nowConnected)
                    {
                        _connectedToNw	= true;
                        URLReachabilityChange(_connectedToNw);
                    }
                }
                else
                {
                    if (!_nowConnected)
                    {
                        _connectedToNw	= false;
                        URLReachabilityChange(_connectedToNw);
                    }
                }

                // Wait
                yield return new WaitForSeconds(_dt);
            }
        }
Exemplo n.º 2
0
        public override void Initialise()
        {
            base.Initialise();

            NetworkConnectivitySettings _settings = NPSettings.NetworkConnectivity;

            // Starts scheduler to monitor connectivity
            StopCoroutine("MonitorNetworkConnectivity");
            StartCoroutine(MonitorNetworkConnectivity(_settings));
        }
Exemplo n.º 3
0
        public override void Initialise()
        {
            NetworkConnectivitySettings _settings = NPSettings.NetworkConnectivity;

            Plugin.Call(NativeInfo.Methods.INITIALIZE);

            //Stop previous if any polling happening.
            StopCoroutine("MonitorNetworkConnectivity");
            StartCoroutine(MonitorNetworkConnectivity(_settings));
        }
Exemplo n.º 4
0
        public override void Initialise()
        {
            Console.Log(Constants.kDebugTag, "[NetworkConnectivity] Initialised");

            NetworkConnectivitySettings _settings = NPSettings.NetworkConnectivity;

            // Starts scheduler to monitor connectivity
            StopCoroutine("MonitorNetworkConnectivity");
            StartCoroutine(MonitorNetworkConnectivity(_settings));
        }
Exemplo n.º 5
0
        public override void Initialise()
        {
            base.Initialise();

            NetworkConnectivitySettings _settings = NPSettings.NetworkConnectivity;

            Plugin.Call(Native.Methods.INITIALIZE, _settings.HostAddress,
                        _settings.Android.Port,
                        _settings.TimeGapBetweenPolling,
                        _settings.TimeOutPeriod,
                        _settings.MaxRetryCount);
        }