//obj: blacklist // //a list of users to ignore messages from, passed in from <THreadController> /** * The constructor for <CommandConsumer> * Generates the configuraiton for the Kafka client. * * Parameters: * controller - the <ThreadConstroller> that created this object * blacklist - a refrence to the shared <blacklist> object owned by <ThreadConstroller> */ public CommandConsumer(ThreadController controller) { this.controller = controller; config = new ConsumerConfig { BootstrapServers = server, GroupId = Guid.NewGuid().ToString(), EnableAutoCommit = true, StatisticsIntervalMs = 5000, SessionTimeoutMs = 6000, AutoOffsetReset = AutoOffsetReset.Latest, EnablePartitionEof = true }; source = new CancellationTokenSource(); canceltoken = source.Token; }
//Function: Main //The main method, contains an input loop for console interactivity static void Main(string[] args) { bool active = true; //This bool keeps the loop going until the user chooses to exit controller = new ThreadController(); //This class will handle all of the functionality of the Application while (active) { var input = Console.ReadLine(); string command; string parameter; if (input.Contains(" "))//this code block seperates commands with multiple qords into a command and a parameter { command = input.Substring(0, input.IndexOf(" ")).Trim(); parameter = input.Substring(input.IndexOf(" "), input.Length - command.Length).Trim(); } else { command = input; parameter = ""; } Console.WriteLine("COMMAND----------> " + input); if (command.Equals("Add-Channel")) { controller.addClient(parameter); } else if (command.Equals("Drop-Channel")) { controller.dropClient(parameter); } else if (command.Equals("List-Channels")) { Console.WriteLine("The active threads are:"); controller.listThreads(); } else if (command.Equals("Count")) { Console.WriteLine("The message queue has " + controller.queueSize() + " messages in it right now"); } else if (command.Equals("Exit")) { controller.exit(); active = false; } } }