static void Main(string[] args) { MessageMaker msgMaker = new MessageMaker(); Console.Write("\nStarting Test Executive"); Console.Write("\n=============================\n"); Message msg = new Message(); HiResTimer timer = new HiResTimer(); Console.Title = "Write Client"; WriteClient writeClient = new WriteClient(); if (args.Length == 2) { writeClient.numMsg = Convert.ToInt32(args[1]); } writeClient.processCommandLine(args); string localPort = Util.urlPort(writeClient.localUrl); string localAddr = Util.urlAddress(writeClient.localUrl); Receiver rcvr = new Receiver(localPort, localAddr, timer); if (rcvr.StartService()) { rcvr.doService(rcvr.defaultServiceAction()); } Sender sndr = new Sender(writeClient.localUrl); // Sender needs localUrl for start message XDocument xmlInput = writeClient.GetInputFromXml(); var results = xmlInput.Descendants("element"); writeClient.sendMessageToServer(results, timer, msgMaker, sndr, rcvr); Console.Write("\n sender's url is {0}", writeClient.localUrl); Console.Write("\n attempting to connect to {0}\n", writeClient.remoteUrl); //Wait until all messages from server are received. while (rcvr.count < writeClient.numMsg) { sndr.SendWriterLatency(rcvr.totalExecutionTime / rcvr.count); } msg.content = "done"; msg.fromUrl = writeClient.localUrl; msg.toUrl = writeClient.remoteUrl; sndr.sendMessage(msg); Util.waitForUser(); sndr.SendWriterLatency(rcvr.totalExecutionTime / rcvr.count); rcvr.shutDown(); sndr.shutdown(); }
//args[0] is an option switch //when it is "showMessage", messages are logged to the console. //args[1] is used to define the number of write client. static void Main(string[] args) { int port = 8082; if (args.Length > 1) { port = int.Parse(args[1]); } string remoteUrl = "http://localhost:8080/CommService"; string localUrl = string.Format("http://localhost:{0}/CommService", port); WriteClient writeClient1 = new WriteClient(localUrl, remoteUrl); writeClient1.processCommandLine(args); if (writeClient1.readXmlFile("XMLfile.xml")) { writeClient1.sendMessages(); } Utilities.waitForUser(); writeClient1.shutDown(); Console.Write("\n\n"); }