Ejemplo n.º 1
0
        public static void Main(string[] args)
        {
            var logRepository = LogManager.GetRepository(Assembly.GetEntryAssembly());

            XmlConfigurator.Configure(logRepository, new FileInfo(args[2]));
            _userName                   = args[0];
            _coordinatorUrl             = args[3];
            _test                       = bool.Parse(args[5]);
            _magicNumber                = ulong.Parse(args[6]);
            _dbOptions                  = new DbContextOptionsBuilder <Repository>().UseNpgsql(args[4]).Options;
            _dotaClient                 = new DotaClient();
            _dotaClient.OnDota2Launched = () => {
                _dotaClient.LeaveLobby(); //Try leaving the current lobby on startup in case the client was shut down forcefully and couldn't leave the lobby before.
                StartCoordinatorTaskPoller();
                StartMatchHistoryRequester();
                StartLobbyTimeoutChecker();
            };
            _dotaClient.OnLobbyUpdate                = OnLobbyUpdate;
            _dotaClient.OnChatMessage                = OnChatMessage;
            _dotaClient.OnChatChannelJoined          = OnChatChannelJoin;
            _dotaClient.OnPlayerMatchHistoryResponse = OnGetPlayerMatchHistoryResponse;
            _dotaClient.OnCacheUnsubscribed          = OnCacheUnsubscribed;
            _dotaClient.OnReadyUpStatus              = OnReadyUpStatus;
            _dotaClient.Connect(_userName, args[1]);
        }
Ejemplo n.º 2
0
 private static void StartLobbyTimeoutChecker()
 {
     _lobbyTimeoutChecker = new Timer((x) => {
         try {
             if (_lobbyCreated.HasValue && _game != null && _lobbyCreated.Value.AddMinutes(_game.LobbyTimeout) < DateTime.UtcNow)
             {
                 _logger.Info("Lobby timed out");
                 if (_channelId != 0 && !_test)
                 {
                     _dotaClient.SendChatMessage(_channelId, _game.LobbyTimeoutMessage);
                 }
                 SendLobbyLeftToCoordinator();
                 LeaveLobby();
                 _dotaClient.LeaveLobby();
             }
         } catch (Exception e) {
             _logger.Error("Error while checking lobby timeout", e);
         }
     }, null, 0, 5000);
 }