private void EngineController_DataReceived(object sender, ChessCommandReceivedEventArgs e) { if (ResponseIsNotNullOrEmpty(e.Data)) { if (e.Data.StartsWith(READYOK)) { CommandResponseReceived = true; } } }
/// <summary> /// Occurs when data is received from the engine controller after sending this command. /// </summary> /// <param name="sender"></param> /// <param name="e"></param> private void ChessEngineController_DataReceived(object sender, ChessCommandReceivedEventArgs e) { var data = e.Data; if (ResponseIsNotNullOrEmpty(data)) { Status = GetRegistrationStatus(data); if (Status == RegistrationStatus.Error || Status == RegistrationStatus.Ok) { CommandResponseReceived = true; } } }
private void _chessEngineProcess_OutputDataReceived(object sender, DataReceivedEventArgs e) { if (!string.IsNullOrWhiteSpace(e.Data)) { var chessCommandArgs = new ChessCommandReceivedEventArgs(e.Data); if (e.Data.StartsWith("Unknown command")) { OnRaiseErrorReceived(sender, chessCommandArgs); } else { OnRaiseDataReceived(sender, chessCommandArgs); } } }
/// <summary> /// Fires when data is received from the chess engine. /// </summary> /// <param name="sender">Object that raised the event.</param> /// <param name="e">Event arguments received from the chess engine.</param> protected virtual void OnRaiseErrorReceived(object sender, ChessCommandReceivedEventArgs e) { ErrorReceived?.Invoke(sender, e); }