Пример #1
0
        public void RunRealPing()
        {
            try
            {
                for (int k = 0; k < _selecteds.Count; k++)
                {
                    int index = _selecteds[k];
                    if (_config.vmess[index].configType == (int)EConfigType.Custom)
                    {
                        continue;
                    }
                    try
                    {
                        if (ConfigHandler.SetDefaultServer(ref _config, index) == 0)
                        {
                            _v2rayHandler.LoadV2ray(_config);
                        }
                        else
                        {
                            return;
                        }
                        Thread.Sleep(1000 * 5);

                        int responseTime = -1;
                        var status       = GetRealPingTime(Global.SpeedPingTestUrl, out responseTime);
                        if (!Utils.IsNullOrEmpty(status))
                        {
                            _updateFunc(index, string.Format("{0}", status));
                        }
                        else
                        {
                            _updateFunc(index, string.Format("{0}ms", responseTime));
                        }
                    }
                    catch (Exception ex)
                    {
                        Utils.SaveLog(ex.Message, ex);
                    }
                }

                Thread.Sleep(1);
            }
            catch (Exception ex)
            {
                Utils.SaveLog(ex.Message, ex);
            }
        }
Пример #2
0
        private int ServerSpeedTestSub(int index, string url)
        {
            if (index >= _selecteds.Count)
            {
                return(-1);
            }

            if (ConfigHandler.SetDefaultServer(ref _config, _selecteds[index]) == 0)
            {
                _v2rayHandler.LoadV2ray(_config);

                testCounter++;

                v2rayUpdateHandle2.DownloadFileAsync(_config, url, true);

                return(0);
            }
            else
            {
                return(-1);
            }
        }