Пример #1
0
        public string GetConnectionType()
        {
            LoadCookiesIfNeeded();
            var status = _website.LoadPage(_connectionStatusUrl);
            var match  = Regex.Match(status, "<CurrentNetworkType>(?<mode>\\d+)</CurrentNetworkType>");

            if (match.Success)
            {
                var mode = match.Groups["mode"].Value;
                return(mode);
            }

            if (status.Contains("timed out"))
            {
                _logger.Warn("Response from server timed out.");
            }
            else if (status.Contains("125002"))
            {
                _logger.Warn("Probably router rebooted or Session Lost. Trying to load home page to get cookies again... ");

                hasPublicKeys = false;
                _website.LoadPage(_homePageUrl);
            }
            else
            {
                _logger.Warn("Couldn't get proper connection type (<CurrentNetworkType> tag). Response was: {0}", status);
            }

            return(string.Empty);
        }