//initiates the FileContentRtr to get all info of a text file protected override void ProcessMessages() { while (true) { ServiceMessage msg = bq.deQ(); FileContentRtr filecontent = new FileContentRtr(); //string message = List <List <string> > result = filecontent.getContent(msg.filename); /* var appDomain = AppDomain.CurrentDomain; * string temp1 = appDomain.BaseDirectory; * Directory.SetCurrentDirectory(temp1);*/ //Console.Write("\n {0} Recieved Message:\n", msg.TargetCommunicator); //msg.ShowMessage(); //Console.Write("\n Query processing is an exercise for students\n"); if (msg.Contents == "quit") { break; } ServiceMessage reply = ServiceMessage.MakeQueryMessage("client-echo", "filecontent", result, "reply from filecontent"); reply.TargetUrl = msg.SourceUrl; reply.SourceUrl = msg.TargetUrl; AbstractMessageDispatcher dispatcher = AbstractMessageDispatcher.GetInstance(); dispatcher.PostMessage(reply); } }
//initiates the QueryHandler for metadata query processing and text query processing protected override void ProcessMessages() { while (true) { ServiceMessage msg = bq.deQ(); if (!msg.ResourceName.Equals("textquery")) { QueryHandler queryhandler = new QueryHandler(); List <List <string> > results = queryhandler.MetaQuery(msg.nlist); Console.Write("\n {0} Recieved Message:\n", msg.TargetCommunicator); msg.ShowMessage(); //Console.Write("\n Query processing is an exercise for students\n"); if (msg.Contents == "quit") { break; } ServiceMessage reply = ServiceMessage.MakeQueryMessage("client-echo", "query", results, "reply from query"); reply.TargetUrl = msg.SourceUrl; reply.SourceUrl = msg.TargetUrl; AbstractMessageDispatcher dispatcher = AbstractMessageDispatcher.GetInstance(); dispatcher.PostMessage(reply); } else { TextQueryHandler textqueryhandler = new TextQueryHandler(); List <List <string> > results = textqueryhandler.textQuery(msg.nlist); if (msg.Contents == "quit") { break; } ServiceMessage reply = ServiceMessage.MakeQueryMessage("client-echo", "query", results, "reply from tquery"); reply.TargetUrl = msg.SourceUrl; reply.SourceUrl = msg.TargetUrl; AbstractMessageDispatcher dispatcher = AbstractMessageDispatcher.GetInstance(); dispatcher.PostMessage(reply); } } }