protected override void OnDisconnected() { Trace.WriteLine("Подключение потеряно!"); _combatLogListener.Stop(); _gameStateListener.Stop(); OnDisconnect(); }
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(); }