Beispiel #1
0
        public void ProcessNewMatches(object state)
        {
            var gameCoordinatorClient = new GameCoordinatorClient(myLoggerFactory);

            using var scope = myScopeFactory.CreateScope();
            var shareCodeRepository = scope.ServiceProvider.GetRequiredService <ShareCodeRepository>();
            var matchRepository     = scope.ServiceProvider.GetRequiredService <MatchRepository>();

            PruneShareCodeRepository(shareCodeRepository, matchRepository);

            try
            {
                if (!shareCodeRepository.HasRetryableCodes())
                {
                    myLogger.LogInformation("No retryable share codes available right now");
                    return;
                }

                gameCoordinatorClient.ConnectAndLogin();

                ProcessNewMatches(gameCoordinatorClient, shareCodeRepository, matchRepository);
                Thread.Sleep(5000);
            }
            catch (GameCoordinatorException e)
            {
                myLogger.LogWarning($"Exception while trying to process new matches: {e.Message}");
            }
            finally
            {
                matchRepository.Dispose();
                shareCodeRepository.Dispose();
                scope.Dispose();
                gameCoordinatorClient.Dispose();
            }
        }
Beispiel #2
0
        public void CheckForRankChanges(object state)
        {
            var gameCoordinatorClient = new GameCoordinatorClient(myLoggerFactory);

            try
            {
                gameCoordinatorClient.ConnectAndLogin();
                UpdateRanksForPlayers(gameCoordinatorClient);
            }
            catch (GameCoordinatorException e)
            {
                myLogger.LogWarning($"Exception while trying to update ranks: {e.Message}");
            }
            finally
            {
                gameCoordinatorClient.Dispose();
            }
        }