private void RunApp() { var auditStream = config.AuditStream; challengeServerClient = new ChallengeServerClient(config.Hostname, config.Port, config.JourneyId, config.UseColours); try { var journeyProgress = challengeServerClient.GetJourneyProgress(); auditStream.WriteLine(journeyProgress); var availableActions = challengeServerClient.GetAvailableActions(); auditStream.WriteLine(availableActions); bool noActionsAvailable = availableActions.Contains("No actions available."); if (noActionsAvailable) { recordingSystem.TellToStop(); return; } var userInput = userInputCallback.Get(); auditStream.WriteLine("Selected action is: " + userInput); if (userInput.Equals("deploy")) { implementationRunner.Run(); var lastFetchedRound = RoundManagement.GetLastFetchedRound(); recordingSystem.NotifyEvent(lastFetchedRound, RecordingEvent.ROUND_SOLUTION_DEPLOY); } var actionFeedback = challengeServerClient.SendAction(userInput); if (actionFeedback.Contains("Round time for")) { var lastFetchedRound = RoundManagement.GetLastFetchedRound(); recordingSystem.NotifyEvent(lastFetchedRound, RecordingEvent.ROUND_COMPLETED); } if (actionFeedback.Contains("All challenges have been completed")) { recordingSystem.TellToStop(); } config.AuditStream.WriteLine(actionFeedback); var roundDescription = challengeServerClient.GetRoundDescription(); RoundManagement.SaveDescription(recordingSystem, roundDescription, auditStream); } catch (ServerErrorException) { auditStream.WriteLine("Server experienced an error. Try again in a few minutes."); } catch (OtherCommunicationException) { auditStream.WriteLine("Client threw an unexpected error. Try again."); } catch (ClientErrorException e) { // The client sent something the server didn't expect. auditStream.WriteLine(e.Message); } }
private string ExecuteAction(String userInput) { var actionFeedback = challengeServerClient.SendAction(userInput); config.AuditStream.WriteLine(actionFeedback); if (actionFeedback.Contains("Round time for")) { var lastFetchedRound = RoundManagement.GetLastFetchedRound(); recordingSystem.NotifyEvent(lastFetchedRound, RecordingEvent.ROUND_COMPLETED); } return(challengeServerClient.GetRoundDescription()); }