/// <summary>
        /// Method for server's receive thread to run to process messages
        /// </summary>
        void rcvThreadProc()
        {
            while (true)
            {
                Message msg = comm.rcvr.GetMessage();
                msg.time = DateTime.Now;
                switch (msg.type)
                {
                case "TestRequest":
                {
                    Console.Write("\n  TEST HARNESS RECEIVE TestRequest------------------- - Req #2");
                    Console.Write("\n  {0} received message:", comm.name);
                    msg.showMsg();
                    inQ_.enQ(msg);
                    break;
                }

                default:
                {
                    Console.Write("\n  TEST HARNESS RECEIVE--------------------------------");
                    Console.Write("\n  {0} received message:", comm.name);
                    msg.showMsg();
                    break;
                }
                }
                if (msg.body == "quit")
                {
                    break;
                }
            }
        }
Exemple #2
0
        //----< use private service method to receive a message >--------

        void rcvThreadProc()
        {
            while (true)
            {
                Message msg = comm.rcvr.GetMessage();
                msg.time = DateTime.Now;

                if (msg.from != "Repository")
                {
                    Console.Write("\n  {0} received message:", comm.name);
                    msg.showMsg();
                }

                // querying capability for first 10 responses
                if (msg.from == "Repository")
                {
                    List <string> files_ = msg.files;
                    Console.Write("\n  first 10 reponses to query: \n");
                    for (int i = 0; i < 10; ++i)
                    {
                        if (i == files_.Count())
                        {
                            break;
                        }
                        Console.Write("\n  " + files_[i]);
                    }
                }


                if (msg.body == "quit")
                {
                    break;
                }
            }
        }
Exemple #3
0
        //----< processing for send thread >-----------------------------

        void ThreadProc()
        {
            tryCount = 0;
            while (true)
            {
                Message msg = sndBlockingQ.deQ();
                if (msg.to != currEndpoint)//check
                {
                    currEndpoint = msg.to;
                    CreateSendChannel(currEndpoint);//infact creating a proxy
                }
                while (true)
                {
                    try
                    {
                        if(msg.type== "FileReply"|| msg.type == "FileUpload")
                        {                           
                            string filename = Path.GetFileName(msg.body);
                            Console.Write("\n  SEND==============================================");
                            Console.Write("\n  sending file {0}", filename);
                            SendFile(channel, msg.body);
                            if (msg.author== "RepPulse")
                            {
                                //Console.Write("\n  deleting file {0}", msg.body);
                                System.IO.File.Delete(msg.body);
                            }
                        }
                        else
                        {
                            channel.PostMessage(msg);//put in sender's queue
                            Console.Write("\n  SEND==============================================");
                            Console.Write("\n  posted message from {0} to {1}", name, msg.to);
                            msg.showMsg();
                        }
                        tryCount = 0;
                        break;
                    }
                    catch (Exception ex)
                    {
                        Console.Write("\n  connection failed");
                        Console.Write("\n  {0}", ex);
                        if (++tryCount < MaxCount)
                            Thread.Sleep(100);
                        else
                        {
                            Console.Write("\n  {0}", "can't connect\n");
                            currEndpoint = "";
                            tryCount = 0;
                            break;
                        }
                    }
                }
                if (msg.body == "quit")
                    break;
            }
        }
        //----< this thrdProc() used only for testing, below >-----------

        public void thrdProc()
        {
            while (true)
            {
                Message msg = rcvr.GetMessage();
                msg.showMsg();
                if (msg.body == "quit")
                {
                    break;
                }
            }
        }
        //----< use private service method to receive a message >--------

        void rcvThreadProc()
        {
            while (true)
            {
                Message msg = comm.rcvr.GetMessage();
                //Console.Write("\n  RECEIVE---------------------");
                //Console.Write("\n  {0} received message:", comm.name);
                //msg.showMsg();
                switch (msg.type)
                {
                case "TestResults":
                {
                    Console.Write("\n  CLIENT RECEIVE TestResults---------------------- - Req #7");
                    Console.Write("\n  {0} received message:", comm.name);
                    msg.showMsg();
                    break;
                }

                case "ResultReply":
                {
                    Console.Write("\n  CLIENT RECEIVE ResultReply----------------------- - Req #9");
                    Console.Write("\n  {0} received message:", comm.name);
                    msg.showMsg();
                    break;
                }

                default:
                {
                    Console.Write("\n  CLIENT RECEIVE-----------------------------------");
                    Console.Write("\n  {0} received message:", comm.name);
                    msg.showMsg();
                    break;
                }
                }
                if (msg.body == "quit")
                {
                    break;
                }
            }
        }
Exemple #6
0
        static void Main(string[] args)
        {
            Console.Write("\n  Testing Message Class");
            Console.Write("\n =======================\n");

            Message msg = new Message();

            msg.to     = "http://localhost:8080/ICommunicator";
            msg.from   = "http://localhost:8081/ICommunicator";
            msg.author = "Fawcett";
            msg.type   = "TestRequest";
            msg.showMsg();
            Console.Write("\n\n");
        }
 void rcvThreadProc()
 {
     while (true)
     {
         Message msg = comm.rcvr.GetMessage();
         msg.time = DateTime.Now;
         m       += "\n  " + comm.name + " sent message:";
         m       += msg.showMsg();
         if (msg.body == "quit")
         {
             break;
         }
     }
 }
 void rcvThreadProc()
 {
     while (true)
     {
         Message msg = comm.rcvr.GetMessage();
         msg.time = DateTime.Now;
         Console.Write("\n  {0} received message:", comm.name);
         msg.showMsg();
         if (msg.body == "quit")
         {
             break;
         }
     }
 }
        static void Main(string[] args)
        {
            Console.Write("\n  Testing Message with Serialized TestRequest");
            Console.Write("\n ---------------------------------------------\n");

            Message msg = new Message();

            msg.to     = "http://localhost:8080/ICommunicator";
            msg.from   = "http://localhost:8081/ICommunicator";
            msg.author = "Fawcett";
            msg.type   = "TestRequest";
            Console.Write("\n\n");

            Console.Write("\n  Testing testRequest");
            Console.Write("\n ---------------------");
            testElement te1 = new testElement("test1");

            te1.addDriver("td1.dll");
            te1.addCode("tc1.dll");
            te1.addCode("tc2.dll");
            testElement te2 = new testElement("test2");

            te2.addDriver("td2.dll");
            te2.addCode("tc3.dll");
            te2.addCode("tc4.dll");
            testRequest tr = new testRequest();

            tr.author = "Jim Fawcett";
            tr.tests.Add(te1);
            tr.tests.Add(te2);
            msg.body = tr.ToXml();

            Console.Write("\n  Serialized TestRequest:");
            Console.Write("\n -------------------------\n");
            Console.Write(msg.body.shift());

            Console.Write("\n  TestRequest Message:");
            Console.Write("\n ----------------------");
            msg.showMsg();

            Console.Write("\n  Testing Deserialized TestRequest");
            Console.Write("\n ----------------------------------\n");
            testRequest trDS = msg.body.FromXml <testRequest>();

            Console.Write(trDS.showThis());
        }
Exemple #10
0
        static void Main(string[] args)
        {
            Message msg = new Message();

            msg.to     = "http://localhost:8080/ICommunicator";
            msg.from   = "http://localhost:8081/ICommunicator";
            msg.author = "Manjunath";

            testElement te1 = new testElement("test1");
            testElement te2 = new testElement("test2");
            testElement te3 = new testElement("test3");
            testElement tlg = new testElement("loggerTest");

            te2.addDriver("td1.dll");
            te2.addCode("tc1.dll");
            te1.addDriver("testdriver.dll");
            te1.addCode("testedcode.dll");
            te3.addDriver("anothertestdriver.dll");
            te3.addCode("anothertestedcode.dll");
            tlg.addDriver("logger.dll");
            testRequest tr = new testRequest();

            tr.author = "Manjunath";
            tr.tests.Add(te1);
            tr.tests.Add(te2);
            tr.tests.Add(te3);
            tr.tests.Add(tlg);
            msg.body = tr.ToString();

            Console.Write("\n  Serialized TestRequest:");
            Console.Write("\n -------------------------\n");
            Console.Write(msg.body.shift());

            Console.Write("\n  TestRequest Message:");
            Console.Write("\n ----------------------");
            msg.showMsg();

            Console.Write("\n  Testing Deserialized TestRequest");
            Console.Write("\n ----------------------------------\n");
            TestRequest trDS = msg.body.FromXml <TestRequest>();

            Console.Write(trDS.showThis());
        }
        void rcvThreadProc()
        {
            while (true)
            {
                Message msg = comm.rcvr.GetMessage();
                msg.time = DateTime.Now;
                //Console.Write("\n  REPOSITORY RECEIVE---------------------");
                //Console.Write("\n  {0} received message:", comm.name);
                //msg.showMsg();
                switch (msg.type)
                {
                case "FilesRequest":
                {
                    Console.Write("\n  REPOSITORY RECEIVE FilesRequest----------------");
                    Console.Write("\n  {0} received message:", comm.name);
                    msg.showMsg();
                    string        body  = msg.body;
                    List <string> files = body.FromXml <List <string> >();
                    //send messages to deliver files required
                    for (int i = 0; i < files.Count() - 1; i++)
                    {
                        string  file      = files[i];
                        string  fqSrcFile = repoStoragePath + file;
                        Message fpMsg     = makeFileReplyMessage(msg, fqSrcFile);
                        sendMessage(fpMsg);
                    }
                    //send message to deliver a flag file
                    makePulseFile(files.Last());
                    string  pulseFile = repoStoragePath + files.Last();
                    Message Msg       = makeFileReplyMessage(msg, pulseFile);
                    Msg.author = "RepPulse";
                    sendMessage(Msg);
                    break;
                }

                case "SendLog":
                {
                    Console.Write("\n  REPOSITORY RECEIVE Log--------------------------- - Req #7");
                    Console.Write("\n  {0} received message:", comm.name);
                    msg.showMsg();
                    saveLog(msg);
                    break;
                }

                case "ResultsQuery":
                {
                    Console.Write("\n  REPOSITORY RECEIVE Test Results/Log Query--------- - Req #7");
                    Console.Write("\n  {0} received message:", comm.name);
                    msg.showMsg();
                    List <string>  queryFiles          = queryLogs(msg.body);
                    List <Message> ResultReplyMessages = makeResultReplyMessages(msg, queryFiles);
                    foreach (Message replyMsg in ResultReplyMessages)
                    {
                        sendMessage(replyMsg);
                    }
                    break;
                }

                case "ContentQuery":
                {
                    Console.Write("\n  REPOSITORY RECEIVE Log List Query------------------");
                    Console.Write("\n  {0} received message:", comm.name);
                    msg.showMsg();
                    Message qfMsg = queryFileNames(msg);
                    sendMessage(qfMsg);
                    break;
                }

                default:
                    break;
                }
                if (msg.body == "quit")
                {
                    break;
                }
            }
        }
        static void Main(string[] args)
        {
            int    length = 0;
            Client client = new Client();

            Console.Write("\n  Testing Client Demo");
            string url = "http://localhost:8080/FileService";

            Console.Write("\n  Client of File Transfer Service");
            Console.Write("\n =================================\n");

            IFileService fs = null;

            while (true)
            {
                try
                {
                    fs = CreateChannel(url);
                    break;
                }
                catch
                {
                    Console.Write("\n  connection to service failed {0} times - trying again", ++length);
                    Thread.Sleep(500);
                    continue;
                }
            }
            Console.Write("\n  Connected to {0}\n", url);
            string storedlocation = "Sending";


            string location = Path.GetFullPath(storedlocation);

            Console.Write("\n  retrieving files from\n  {0}\n", location);
            string[] files = Directory.GetFiles(location);
            foreach (string file in files)
            {
                string filename = Path.GetFileName(file);
                Console.Write("\n  sending file {0}", filename);
                if (!sending(fs, file))
                {
                    Console.Write("\n  could not send file");
                }
            }
            Console.Write("\n\n");
            Message msg = client.makeMessage("Manjunath", client.endPoint, client.endPoint);     msg = client.makeMessage("Manjunath", client.endPoint, client.endPoint);

            msg.body = MessageTest.makeTestRequest();
            client.comm.sndr.PostMessage(msg);
            string remoteEndPoint = Comm <Client> .makeEndPoint("http://localhost", 8080);

            msg    = msg.copy_();
            msg.to = remoteEndPoint;
            client.comm.sndr.PostMessage(msg);
            Console.ReadKey();
            Message msg1 = client.results();

            client.showMsg(msg1);
            Console.Write("\n  received query: \"{0}\"", client.messge());
            msg.time  = DateTime.Now;
            client.m += "\n  " + client.comm.name + " sent message:";
            client.m += msg.showMsg();
            Console.WriteLine("{0}", client.m);
            client.wait();
        }