public HttpRateLimitedResponseMessage(HttpResponseMessage response) { HttpResponseMessage = response; HeaderRateLimits = HttpResponseMessage.Headers.GetValue(RateLimitHttpHeader, RateLimitList.FromRiotApiHeader); if (HeaderRateLimits == null) { throw new Exception("Pas de header " + RateLimitHttpHeader + " pour ce HttpResponseMessage"); } }
public HttpRequestQueue(RateLimitList rateLimits) { _rateLimits = rateLimits; _httpClient = new HttpClient(); _semaphore = new SemaphoreSlim(1); _timers = new RateLimitTimerList(); // Init Timers foreach (var rateLimit in _rateLimits) { _timers.Add(new RateLimitTimer(rateLimit)); } }
public int?TimeToWaitForNext(RateLimitList rateLimits) { foreach (var headerLimit in HeaderRateLimits.OrderByDescending(hrl => hrl.Time)) { var rateLimit = rateLimits[headerLimit.Time]; if (rateLimit == null) { continue; } if (headerLimit.Limit < rateLimit.Limit) { continue; } return(headerLimit.Time); } return(null); }