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

                if (msg.body == "quit")
                {
                    break;
                }
                if (msg.type == "testlogs")
                {
                    Console.WriteLine("\n**********************************************************************");
                    Console.WriteLine("\nDemonstrating requirement 9 ,request for logs at repository");
                    msg.showMsg();
                    sendlogs(msg.from, msg.author); //for log requests from clients
                }
                else
                {
                    Console.Write("\n  {0} received message:", comm.name);
                    msg.showMsg();
                }
            }
        }
Exemplo n.º 2
0
        //----< run client demo >----------------------------------------

        static void Main(string[] args)
        {
            Console.Title = "Client 1 Console";
            Console.Write("\n  Testing Client Demo");
            Console.Write("\n =====================\n");
            Client clnt = new Client();

            clnt.comm.sndr.channel = Sender.CreateServiceChannel("http://localhost:8082/StreamService");
            HiResTimer hrt = new HiResTimer();

            hrt.Start();
            clnt.comm.sndr.uploadFile("TestDriver.dll");
            clnt.comm.sndr.uploadFile("TestedCode.dll");
            hrt.Stop();
            Console.WriteLine("\n**********************************************************************");
            Console.WriteLine("\nDemonstrating requirement 12 latency");
            Console.Write(
                "\n\n  total elapsed time for uploading = {0} microsec.\n",
                hrt.ElapsedMicroseconds
                );
            Message msg = clnt.makeMessage("Brahma", clnt.endPoint, clnt.endPoint);

            msg.type = "TestRequest";
            msg      = clnt.makeMessage("Brahma", clnt.endPoint, clnt.endPoint);
            msg.body = MessageTest.makeTestRequest();
            Console.WriteLine("\n**********************************************************************");
            Console.WriteLine("\n Demonstrating requirement 2 : XML messages");
            msg.showMsg();
            string remoteEndPoint = Comm <Client> .makeEndPoint("http://localhost", 8080);

            msg    = msg.copy();
            msg.to = remoteEndPoint;
            clnt.comm.sndr.PostMessage(msg);
            string repository = Comm <Client> .makeEndPoint("http://localhost", 8082);

            msg      = clnt.makeMessage("Brahma", clnt.endPoint, repository);
            msg.type = "testlogs";
            msg.body = "brahma";
            clnt.comm.sndr.PostMessage(msg);
            Console.Write("\n  press key to exit: ");
            Console.ReadKey();
            msg.body = "quit";
            clnt.comm.sndr.PostMessage(msg);
            msg.showMsg();
            Console.Write("\n\n  Press key to terminate client");
            Console.ReadKey();
            Console.Write("\n\n");
            clnt.wait();
            ((IChannel)clnt.comm.sndr).Close();
            Console.Write("\n\n");
        }
Exemplo n.º 3
0
        //----< run client demo >----------------------------------------

        static void Main(string[] args)
        {
            Console.Title = "Client1";
            Console.Write("\n  Client1 ");
            Console.Write("\n =========\n");

            Console.Write("\n  Requirement2: Using a Message-Passing Communication Service built with WCF\n");

            Client client         = new Client();
            string remoteEndPoint = Comm <Client> .makeEndPoint("http://localhost", 8080);

            Message msg = new Message();

            msg.from = client.endPoint;
            msg.body = client.CreateBuildRequest1();
            msg.to   = remoteEndPoint;
            msg.type = "BuildRequest";

            Message msg1 = new Message();

            msg1.from = client.endPoint;
            msg1.body = client.CreateBuildRequest2();
            msg1.to   = remoteEndPoint;
            msg1.type = "BuildRequest";

            Message msg2 = new Message();

            msg2.from = client.endPoint;
            msg2.body = client.CreateBuildRequest3();
            msg2.to   = remoteEndPoint;
            msg2.type = "BuildRequest";

            //sending four build requests to mother builder
            Console.Write("\n   Sending message from {0} to {1}", client.comm.name, msg.to);
            msg.showMsg();
            client.comm.sndr.PostMessage(msg);
            Console.Write("\n   Sending message from {0} to {1}", client.comm.name, msg1.to);
            msg1.showMsg();
            client.comm.sndr.PostMessage(msg1);
            Console.Write("\n   Sending message from {0} to {1}", client.comm.name, msg.to);
            msg.showMsg();
            client.comm.sndr.PostMessage(msg);
            Console.Write("\n   Sending message from {0} to {1}", client.comm.name, msg2.to);
            msg2.showMsg();
            client.comm.sndr.PostMessage(msg2);
            client.wait();
            Console.Write("\n\n");
        }
Exemplo n.º 4
0
        //----< use private service method to receive a message >--------

        void rcvThreadProc()
        {
            while (true)
            {
                Message msg = comm.rcvr.GetMessage();
                msg.time = DateTime.Now;
                if (msg.body == "quit")
                {
                    break;
                }
                if (msg.type == "testlog")
                {
                    Console.WriteLine("\n**********************************************************************");
                    Console.WriteLine("\nDemonstrating requirement 6 ,log from repository");

                    Console.Write("\n  {0} received log:", msg.body);
                }
                else
                {
                    Console.Write("\n  {0} received message:", comm.name);
                    Console.WriteLine("\n**********************************************************************");
                    Console.WriteLine("\nDemonstrating requirement 7 ,logs from repository");
                    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 encrypted message:", comm.name);
         msg.showMsg();
         if (msg.body == "quit")
         {
             break;
         }
         else
         {
             // Console.WriteLine("\n Decrypting the message author:\n");
             //string author = msg.author;
             //string decryptAuthor = DecryptMessage(author);
             //Console.Write(decryptAuthor);
             //Console.WriteLine("\n Decrypting the message from:\n");
             //string from = msg.from;
             //string decryptFrom = DecryptMessage(from);
             //Console.Write(decryptFrom);
             //Console.WriteLine("\n Decrypting the message to:\n");
             //string to = msg.to;
             //string decryptTo = DecryptMessage(to);
             //Console.Write(decryptTo);
             Console.WriteLine("\n Decrypting the message body:\n");
             string body        = msg.body;
             string decryptBody = DecryptMessage(body);
             Console.Write(decryptBody);
         }
     }
 }
    //----< this thrdProc() used only for testing, below >-----------

    public void thrdProc()
    {
      while (true)
      {
        Message msg = rcvr.GetMessage();
        msg.showMsg();
        if (msg.body == "quit")
        {
          break;
        }
      }
    }
Exemplo n.º 7
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");
        }
Exemplo n.º 8
0
        //----< use private service method to receive a message >--------

        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;
                }
            }
        }
Exemplo n.º 9
0
        //----< wait for all threads to finish >-------------------------


        //----< main activity of TestHarness >---------------------------

        public void processMessages()
        {
            AppDomain main = AppDomain.CurrentDomain;

            Console.Write("\n  Starting in AppDomain " + main.FriendlyName + "\n");

            ThreadStart doTests = () => {
                while (true)
                {
                    Message msg = comm.rcvr.GetMessage();
                    msg.time = DateTime.Now;

                    Console.Write("\n  {0} received message:", comm.name);
                    msg.showMsg();
                    Message testRequest = msg;

                    if (testRequest.body == "quit")
                    {
                        inQ_.enQ(testRequest);
                        break;
                    }
                    ITestResults testResults = runTests(testRequest);
                    lock (sync_)
                    {
                        // client_.sendResults(makeTestResultsMessage(testResults));
                        Console.WriteLine("test result{0}\n", makeTestResultsMessage(testResults, testRequest.from, testRequest.to, testRequest.author));
                        comm.sndr.PostMessage(makeTestResultsMessage(testResults, testRequest.from, testRequest.to, testRequest.author));
                    }
                }
            };

            int numThreads = 8;

            Console.WriteLine("\n**********************************************************************");
            Console.WriteLine("\nDemonstrating requirement 4 creating child threads");

            for (int i = 0; i < numThreads; ++i)
            {
                Console.Write("\n  Creating AppDomain thread");
                Thread t = new Thread(doTests);
                threads_.Add(t);
                t.Start();
            }
        }
        static void Main(string[] args)
        {
            Message msg = new Message();
            msg.to = "http://localhost:8080/ICommunicator";
            msg.from = "http://localhost:8081/ICommunicator";
            msg.author = "Sahil Shah";
            msg.type = "TestRequest";
            Console.Write("\n  Testing Message with Serialized TestRequest");
            Console.Write("\n ---------------------------------------------\n");
            TestElement te1 = new TestElement("test1");
            te1.addDriver("td1.dll");
            te1.addCode("tc1.dll");
            te1.addCode("tc2.dll");
            Console.Write("\n  Serialized TestRequest:");
            Console.Write("\n -------------------------\n");
            Console.Write(msg.body.shift());
            msg.showMsg();
#endif
        }
Exemplo n.º 11
0
        static void Main(string[] args)
        {
            Message msg = new Message();

            msg.to     = "http://localhost:8080/ICommunicator";
            msg.from   = "http://localhost:8081/ICommunicator";
            msg.author = "Karthik";
            msg.type   = "TestRequest";

            Console.Write("\n  Testing Message with Serialized TestRequest");
            Console.Write("\n ---------------------------------------------\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 = "Karthik Bangera";
            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());
        }