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); }
/// <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); }
/// <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>(); } }
/// <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>()); } }
/// <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>()); } }
/// <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; }
/// <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); }
/// <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; }