コード例 #1
0
ファイル: EyeTcpClient.cs プロジェクト: orf53975/eye
        protected override void OnDisconnected()
        {
            Trace.WriteLine("Подключение потеряно!");

            _combatLogListener.Stop();
            _gameStateListener.Stop();

            OnDisconnect();
        }
コード例 #2
0
        private static void StartParser(string ip)
        {
            var gamestate = new GameStateListener("127.0.0.1");
            var combatlog = new CombatLogListener(CombatLogFilePath);

            var eyeTcpClient = new EyeTcpClient(gamestate, combatlog, ip, _token);

            eyeTcpClient.Connected    += (sender, entry) => Trace.WriteLine(LogFormat("Парсер запущен!"));
            eyeTcpClient.Disconnected += (sender, entry) =>
            {
                gamestate.Stop();
                StartParser(ip);
            };
            combatlog.DataReceived += (sender, entry) =>
            {
                var gs = entry as CombatLogEntryGameState;
                if (gs == null || gs.State != (int)Map.GameState.DOTA_GAMERULES_STATE_POST_GAME)
                {
                    return;
                }

                gamestate.Stop();
                combatlog.Stop();

                while (IsFileLocked(new FileInfo(CombatLogFilePath)))
                {
                    Thread.Sleep(1000);
                }
                File.Delete(CombatLogFilePath);

                StartParser(ip);
            };
            eyeTcpClient.Connect();
        }