static void Main(string[] args) { Console.Write("\n starting CommService client"); Console.Write("\n =============================\n"); HiResTimer timerReader = new HiResTimer(); Client clnt = new Client(); clnt.processCommandLine(args); string localPort = args[0]; clnt.localUrl = "http://localhost:" + localPort + "/CommService"; string localAddr = Util.urlAddress(clnt.localUrl); Receiver rcvr = new Receiver(localPort, localAddr); rcvr.setTimerFromClient(timerReader); clnt.startRcvrService(rcvr); Sender sndr = new Sender(clnt.localUrl); // Sender needs localUrl for start message MessageMaker readerInput = new MessageMaker(); string fileName = ".\\ReaderClientInput.xml"; Message msg = new Message(); int numRequests = Convert.ToInt32(args[1]); XDocument xmldoc = XDocument.Load(fileName); var requests = xmldoc.Descendants("Request"); int requestCount = 0, i = 0; List <XElement> totalrequest = new List <XElement>(); while (i < numRequests) //set the specified number of requests to send { totalrequest.Add(requests.ElementAt(i)); i++; } timerReader.Start(); foreach (var request in totalrequest) //send each request to the message maker to create a message { msg = new Message(); msg = readerInput.makeMessage(clnt.localUrl, clnt.remoteUrl, request); Console.Title = "Reader Client to query the NoSQl database: Querying " + (++requestCount) + " requests"; if (!sndr.Connect(msg.toUrl)) //send url of the destination to the sender { Console.Write("\n could not connect in {0} attempts", sndr.MaxConnectAttempts); sndr.shutdown(); rcvr.shutDown(); return; } Thread.Sleep(700); while (true) { clnt.printMessage(msg); //print the message contents if (!sndr.sendMessage(msg)) // send the message to the sender { return; } Thread.Sleep(100); break; } sndr.sendLatencyReader(rcvr.avgLatency); } Console.Write("\n Sender's url is {0}", msg.fromUrl); Console.Write("\n Attempting to connect to {0}\n", msg.toUrl); msg.content = "done"; sndr.sendMessage(msg); Util.waitForUser(); rcvr.shutDown(); sndr.shutdown(); }
static void Main(string[] args) { Console.Write("\n starting CommService client"); Console.Write("\n =============================\n"); HiResTimer timerReader = new HiResTimer(); Client clnt = new Client(); clnt.processCommandLine(args); string localPort = args[0]; clnt.localUrl = "http://localhost:" + localPort + "/CommService"; string localAddr = Util.urlAddress(clnt.localUrl); Receiver rcvr = new Receiver(localPort, localAddr); rcvr.setTimerFromClient(timerReader); clnt.startRcvrService(rcvr); Sender sndr = new Sender(clnt.localUrl); // Sender needs localUrl for start message MessageMaker readerInput = new MessageMaker(); string fileName = ".\\ReaderClientInput.xml"; Message msg = new Message(); int numRequests = Convert.ToInt32(args[1]); XDocument xmldoc = XDocument.Load(fileName); var requests = xmldoc.Descendants("Request"); int requestCount = 0, i = 0; List<XElement> totalrequest = new List<XElement>(); while (i < numRequests) { //set the specified number of requests to send totalrequest.Add(requests.ElementAt(i)); i++;} timerReader.Start(); foreach (var request in totalrequest) { //send each request to the message maker to create a message msg = new Message(); msg = readerInput.makeMessage(clnt.localUrl, clnt.remoteUrl, request); Console.Title = "Reader Client to query the NoSQl database: Querying " + (++requestCount) + " requests"; if (!sndr.Connect(msg.toUrl)) { //send url of the destination to the sender Console.Write("\n could not connect in {0} attempts", sndr.MaxConnectAttempts); sndr.shutdown(); rcvr.shutDown(); return; } Thread.Sleep(700); while (true) { clnt.printMessage(msg); //print the message contents if (!sndr.sendMessage(msg)) // send the message to the sender return; Thread.Sleep(100); break;} sndr.sendLatencyReader(rcvr.avgLatency);} Console.Write("\n Sender's url is {0}", msg.fromUrl); Console.Write("\n Attempting to connect to {0}\n", msg.toUrl); msg.content = "done"; sndr.sendMessage(msg); Util.waitForUser(); rcvr.shutDown(); sndr.shutdown(); } } }