//thread function to send source files to the builder processes public void sendSourceFiles() { while (true) { CommMessage rcvmsg = cm.getMessage(); rcvmsg.show(); if (rcvmsg.command == "sendsourcefiles") { //connect before postFile CommMessage csndMsg = new CommMessage(CommMessage.MessageType.request); csndMsg.command = "connect"; csndMsg.author = "Nishant Agrawal"; csndMsg.to = rcvmsg.from; csndMsg.from = "http://localhost:" + "9090/RepoMock"; cm.postMessage(csndMsg); Console.WriteLine("\nSending source files to builderProcess {0} from repomock checking the arguments of 'sendsourcefiles' message from builder using WCF...\n----------------------------------------------------\n", rcvmsg.from); foreach (string fileName in rcvmsg.arguments) { cm.postFile(fileName, rcvmsg.from, rcvmsg.fromStorage); } csndMsg.command = "sourceFilesSent"; cm.postMessage(csndMsg); } } }
//----< define processing for GUI's receive thread >------------- void rcvThreadProc() { Console.Write("\n starting repo's receive thread"); while (true) { CommMessage msg = cm.getMessage(); msg.show(); if (msg.command == "sendsourcefiles") sendSourceFiles(msg); else if (msg.command == "getAllFiles") { getAllFiles("*.cs"); Console.WriteLine("\nSending a message back to the client with the source file names as message arguments."); } else if (msg.command == "getXmlFiles") { getAllFiles("*.xml"); Console.WriteLine("\nSending a message back to the client with the xml file names as message arguments."); } else if (msg.command == "createRequest") createRequest(msg); else if (msg.command == "sendSelecXml") sendRequests(msg); } }
//thread function to handle the received messages on the receiver host public void receiveAction() { while (true) { CommMessage rcvMsg = cm.getMessage(); rcvMsg.show(); if (rcvMsg.command == "ready") { Console.Write("\nEnqueuing ready message on ready queue...\n----------------------------------------------------\n"); readyQueue.enQ(rcvMsg); } else if (rcvMsg.command == "allxmlsent") { //enqueue all files in the blocking queue Console.Write("\nEnqueuing all xml files on a file queue...\n----------------------------------------------------\n"); foreach (string file in rcvMsg.arguments) { requestFiles.enQ(file); } } else if (rcvMsg.command == "killBuilders") { shutBuilders(); } else if (rcvMsg.command == "startBuilders") { count = Int32.Parse(rcvMsg.arguments[0]); allProcess(); } } }
//thread function to handle the received messages on the receiver host public void receiveAction() { while (true) { CommMessage rcvMsg = cm.getMessage(); rcvMsg.show(); if (rcvMsg.command == "ready") { Console.Write("\nEnqueuing ready message on ready queue...\n----------------------------------------------------\n"); readyQueue.enQ(rcvMsg); } else if (rcvMsg.command == "allxmlsent") { getFiles(motherbuilderPath, "*.xml"); //enqueue all files in the blocking queue Console.Write("\nEnqueuing all xml files on a file queue...\n----------------------------------------------------\n"); foreach (string file in files) { requestFiles.enQ(file); } } else if (rcvMsg.command == "killBuilders") { shutBuilders(); } } }
private void threadFunction() { while (true) { CommMessage rcvMsg = cm.getMessage(); rcvMsg.show(); if (rcvMsg.command == "executeTests") { testRequests.enQ(rcvMsg); } } }
static void Main(string[] args) { Console.Write("\n Demonstration of message class"); Console.Write("\n ============================"); CommMessage csndMsg = new CommMessage(CommMessage.MessageType.request); csndMsg.command = "show"; csndMsg.author = "Jim Fawcett"; csndMsg.to = "http://localhost:8081/IPluggableComm"; csndMsg.from = "http://localhost:8081/IPluggableComm"; csndMsg.show(); Console.Write("\n\n"); }
//----< define processing for GUI's receive thread >------------- // pass the Dispatcher's action value to the main thread for execution void rcvThreadProc() { Console.Write("\n starting client's receive thread"); while (true) { CommMessage msg = cm.getMessage(); msg.show(); if (msg.command == null) { continue; } Dispatcher.Invoke(messageDispatcher[msg.command], new object[] { msg }); } }
//thread function to process the received messages on the receiver host private void threadFunction() { while (true) { CommMessage rcvMsg = cm.getMessage(); rcvMsg.show(); if (rcvMsg.command == "xmlFileSent") { string xmlfile = rcvMsg.arguments[0]; //get the file from the storage and its full path string[] xmlFile = Directory.GetFiles(builderPath, xmlfile); string bfileSpec = System.IO.Path.GetFullPath(xmlFile[0]); parseRequest(bfileSpec); //check for files in cache checkCache(); sendRepoRequest(); } else if (rcvMsg.command == "sourceFilesSent") { string[] filePaths = System.IO.Directory.GetFiles(builderPath, "*.dll"); foreach (string filePath in filePaths) { System.IO.File.Delete(filePath); } Console.WriteLine("\nStarting build process for the current test request:\n======================================================== \n"); runProcess(); sendTestHDll(); sendReady(); } else if (rcvMsg.command == "quit") { Process.GetCurrentProcess().Kill(); } } }