Example #1
0
        public static string GetCDNURL(CDNType cdn, bool isSSL)
        {
            string cdnUrl = "";

            switch (cdn)
            {
            case CDNType.AKAMAI:
                cdnUrl = ConfigurationManager.AppSettings["CDNURLAKAMAI"];
                break;

            case CDNType.VERIZONE:
                cdnUrl = ConfigurationManager.AppSettings["CDNURLVERIZONE"];
                break;

            case CDNType.LOCAL:
                cdnUrl = "";
                break;
            }

            if (isSSL)
            {
                cdnUrl = cdnUrl.Replace("http://", "https://");
            }
            return(cdnUrl);
        }
Example #2
0
        /// <summary>
        /// Builds the URL to the Steam Datagram network config file.
        /// </summary>
        /// <param name="type"></param>
        /// <param name="game"></param>
        /// <returns></returns>
        public static Uri DatagramNetworkConfig(CDNType type = CDNType.STANDARD, Games game = Games.DOTA2)
        {
            UriBuilder builder = new UriBuilder("http", GetHostname(type), 80,
                                                StaticDataPath(CDNData.DATAGRAM_NETWORK_CONFIG, game));

            return(builder.Uri);
        }
Example #3
0
 /// <summary>
 /// Retreive the network config from the DOTA 2 CDN
 /// </summary>
 /// <returns>Network config on success, null otherwise.</returns>
 public static NetworkConfig GetNetworkConfig(CDNType type = CDNType.STANDARD, Games game = Games.DOTA2)
 {
     using (var wc = new WebClient())
     {
         var str = wc.DownloadString(DatagramNetworkConfig(type, game));
         JObject obj = JObject.Parse(str);
         return obj.ToObject<NetworkConfig>();
     }
 }
Example #4
0
 /// <summary>
 /// Retreive the network config from the DOTA 2 CDN
 /// </summary>
 /// <returns>Network config on success, null otherwise.</returns>
 public static NetworkConfig GetNetworkConfig(CDNType type = CDNType.STANDARD, Games game = Games.DOTA2)
 {
     using (var wc = new WebClient())
     {
         var     str = wc.DownloadString(DatagramNetworkConfig(type, game));
         JObject obj = JObject.Parse(str);
         return(obj.ToObject <NetworkConfig>());
     }
 }
Example #5
0
        /// <summary>
        /// Retrieve the network config from the DOTA 2 CDN
        /// </summary>
        /// <returns>Network config on success, null otherwise.</returns>
        public static async Task <NetworkConfig> GetNetworkConfig(CDNType type = CDNType.STANDARD, Games game = Games.DOTA2)
        {
            using (var wc = new HttpClient())
            {
                HttpResponseMessage response = await wc.GetAsync(DatagramNetworkConfig(type, game));

                response.EnsureSuccessStatusCode();
                JObject obj = JObject.Parse(await response.Content.ReadAsStringAsync());
                return(obj.ToObject <NetworkConfig>());
            }
        }
Example #6
0
        /// <summary>
        /// Gets the CDN Hostname for a CDN type
        /// </summary>
        /// <param name="type">CDN type</param>
        /// <returns></returns>
        public static string GetHostname(CDNType type)
        {
            switch (type)
            {
                case CDNType.LOCAL:
                    return "localhost";
                case CDNType.STANDARD:
                    return "cdn.dota2.com";
                case CDNType.CHINA:
                    return "cdn.dota2.com.cn";
                case CDNType.TEST:
                    return "cdntest.steampowered.com";
            }

            return null;
        }
Example #7
0
        /// <summary>
        /// Gets the CDN Hostname for a CDN type
        /// </summary>
        /// <param name="type">CDN type</param>
        /// <returns></returns>
        public static string GetHostname(CDNType type)
        {
            switch (type)
            {
            case CDNType.LOCAL:
                return("localhost");

            case CDNType.STANDARD:
                return("cdn.dota2.com");

            case CDNType.CHINA:
                return("cdn.dota2.com.cn");

            case CDNType.TEST:
                return("cdntest.steampowered.com");
            }

            return(null);
        }
Example #8
0
 /// <summary>
 /// Builds the URL to the Steam Datagram network config file.
 /// </summary>
 /// <param name="type"></param>
 /// <param name="game"></param>
 /// <returns></returns>
 public static Uri DatagramNetworkConfig(CDNType type = CDNType.STANDARD, Games game = Games.DOTA2)
 {
     UriBuilder builder = new UriBuilder("http", GetHostname(type), 80,
         StaticDataPath(CDNData.DATAGRAM_NETWORK_CONFIG, game));
     return builder.Uri;
 }