Ejemplo n.º 1
0
        private static async Task ExecuteQueuedMatches(IRealmRoyaleApiClient client)
        {
            // Example fetching siege matches played yesterday at noon

            // To reduce response times the HiRez API introduces time slices to fetch matches from a specific queue
            // An hour is divided into 6 parts (00, 10, 20, 30, 40, 50)

            DateTime date       = DateTime.UtcNow.AddDays(-1);
            var      hourSpan   = new TimeSpan(12, 0, 0);
            var      matchCount = 0;

            for (var min = 0; min < 60; min += 10)
            {
                var minSpan   = new TimeSpan(0, min, 0);
                var queueData = await client.GetMatchIdsByQueueAsync(Queue.Solo, date, hourSpan, minSpan);

                matchCount += queueData.Count;
                Console.WriteLine($"Found {queueData.Count} matches in queue for slice {hourSpan},{minSpan}.");
            }

            // Or simply fetch the data from a whole hour
            var queueDataWholeHour = await client.GetMatchIdsByQueueAsync(Queue.Solo, date, hourSpan);

            Console.WriteLine($"Found {queueDataWholeHour.Count} matches in queue for {hourSpan}");

            Debug.Assert(queueDataWholeHour.Count == matchCount);
        }
 public static Task <IList <MatchIdsByQueue> > GetMatchIdsByQueueAsync(this IRealmRoyaleApiClient operations, Queue queue, string date, string hour,
                                                                       CancellationToken cancellationToken = default)
 {
     return(operations.GetMatchIdsByQueueAsync(((int)queue).ToString(), date, hour, cancellationToken));
 }
 public static Task <IList <MatchIdsByQueue> > GetMatchIdsByQueueAsync(this IRealmRoyaleApiClient operations, Queue queue, DateTime date, TimeSpan hour,
                                                                       TimeSpan?minute = null,
                                                                       CancellationToken cancellationToken = default)
 {
     return(operations.GetMatchIdsByQueueAsync(((int)queue).ToString(), date.ToApiParameterDate(), hour.ToApiParameterHourAndMinTime(minute), cancellationToken));
 }