Esempio n. 1
0
        //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);
                }
            }
        }