示例#1
0
        //----< run client demo >----------------------------------------

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

            Client client = new Client();

            Message msg = client.makeMessage("Karthik", client.endPoint, client.endPoint);

            msg      = client.makeMessage("Karthik", client.endPoint, client.endPoint);
            msg.body = MessageTest.makeTestRequest();
            string remoteEndPoint = Comm <Client> .makeEndPoint("http://localhost", 8088);

            msg    = msg.copy();
            msg.to = remoteEndPoint;
            string author = EncryptMessage(msg.author);
            string body   = EncryptMessage(msg.body);

            msg.body   = body;
            msg.author = author;
            client.comm.sndr.PostMessage(msg);
            Console.Write("\n  press key to exit: ");
            Console.ReadKey();
            msg.to   = client.endPoint;
            msg.body = "quit";
            // client.comm.sndr.PostMessage(msg);
            client.wait();
            Console.Write("\n\n");
        }
示例#2
0
        // forming the test message and uploading files and sending test request
        private void start_test(object sender, RoutedEventArgs e)
        {
            if (testname != "" && fileList.Count > 0 && author != "")
            {
                cc.comm.sndr.channel = Sender.CreateServiceChannel("http://localhost:8082/StreamService");
                foreach (string file in fileList)
                {
                    //uploading files
                    cc.comm.sndr.uploadFile(System.IO.Path.GetFileName(file));
                }
                string to = Comm <Client2> .makeEndPoint("http://localhost", 8080);

                string from = Comm <Client2> .makeEndPoint("http://localhost", 8084);

                Message msg = cc.makeMessage(author, from, to);
                //forming test request
                msg.body = MessageTest.makeTestRequestUI(testname, testcode, testdriver);
                //sending request
                cc.comm.sndr.PostMessage(msg);
            }
            else
            {
                MessageBox.Show("enter author and testname");
                return;
            }
        }
        //----< 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");
        }
示例#4
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");
        }
        static void Main(string[] args)
        {
            Console.Write("\n  Demonstrating Project #4 Channel Prototype");
            Console.Write("\n ============================================\n");

            ChannelDemo <Client> demo1 = new ChannelDemo <Client>();
            string sndrEndPoint1       = Comm <Client> .makeEndPoint("http://localhost", 8080);

            string rcvrEndPoint1 = Comm <Server> .makeEndPoint("http://localhost", 8080);

            demo1.comm.rcvr.CreateRecvChannel(rcvrEndPoint1);
            Thread rcvThread1 = demo1.comm.rcvr.start(demo1.rcvThreadProc);

            Console.Write("\n  rcvr thread id = {0}", rcvThread1.ManagedThreadId);
            Console.WriteLine();
        }
示例#6
0
        static void Main(string[] args)
        {
            Console.Write("\n  Demonstrating Project #4 Channel Prototype");
            Console.Write("\n ============================================\n");

            ChannelDemo <Client> demo1 = new ChannelDemo <Client>();

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

            string rcvrEndPoint1 = Comm <Server> .makeEndPoint("http://localhost", 8080);

            demo1.comm.rcvr.CreateRecvChannel(rcvrEndPoint1);
            Thread rcvThread1 = demo1.comm.rcvr.start(demo1.rcvThreadProc);

            Console.Write("\n  rcvr thread id = {0}", rcvThread1.ManagedThreadId);
            Console.WriteLine();

            ChannelDemo <Server> demo2 = new ChannelDemo <Server>();

            string sndrEndPoint2 = Comm <Client> .makeEndPoint("http://localhost", 8081);

            string rcvrEndPoint2 = Comm <Server> .makeEndPoint("http://localhost", 8081);

            demo2.comm.rcvr.CreateRecvChannel(rcvrEndPoint2);
            Thread rcvThread2 = demo2.comm.rcvr.start(demo2.rcvThreadProc);

            Console.Write("\n  rcvr thread id = {0}", rcvThread2.ManagedThreadId);
            Console.WriteLine();
            Message msg = new Message();

            msg.from = sndrEndPoint1;
            msg.to   = rcvrEndPoint2;
            msg.body = "quit";

            demo1.comm.sndr.PostMessage(msg);
            rcvThread2.Join();
            Console.Write("\n  rcvThread1.state = {0}", rcvThread1.ThreadState.ToString());
            Console.Write("\n  rcvThread2.state = {0}", rcvThread2.ThreadState.ToString());
            msg      = new Message();
            msg.from = sndrEndPoint2;
            msg.to   = rcvrEndPoint1;
            msg.body = "quit";
            Console.Write("\n\n");
        }
 static void Main(string[] args)
 {
   Comm<Cat> comm = new Comm<Cat>();
   string endPoint = Comm<Cat>.makeEndPoint("http://localhost", 8080);
   comm.rcvr.CreateRecvChannel(endPoint);
   comm.rcvr.start(comm.thrdProc);
   comm.sndr = new Sender();
   comm.sndr.CreateSendChannel(endPoint);
   Message msg1 = new Message();
   msg1.body = "Message #1";
   comm.sndr.PostMessage(msg1);
   Message msg2 = new Message();
   msg2.body = "quit";
   comm.sndr.PostMessage(msg2);
   Console.Write("\n  Comm Service Running:");
   Console.Write("\n  Press key to quit");
   Console.ReadKey();
   Console.Write("\n\n");
 }
示例#8
0
        private void show_log(object sender, RoutedEventArgs e)
        {
            if (test_author.Text == "")
            {
                MessageBox.Show("Enter author Name");
                return;
            }
            string to = Comm <Client2> .makeEndPoint("http://localhost", 8082);

            string from = Comm <Client2> .makeEndPoint("http://localhost", 8084);

            Message msg = cc.makeMessage(test_author.Text, from, to);

            msg.type = "testlogs";
            msg.body = test_author.Text;
            cc.comm.sndr.PostMessage(msg);
            //sending request for logs
            RichTextBox rctxtBx = new RichTextBox();

            rctxtBx.Height = 250;
            rctxtBx.Width  = 400;
            rctxtBx.VerticalScrollBarVisibility = ScrollBarVisibility.Auto;
            Paragraph p = rctxtBx.Document.Blocks.FirstBlock as Paragraph;

            p.Margin     = new Thickness(0);
            p.LineHeight = 10;

            try
            {
                fetchResultGrid.Children.Add(rctxtBx);
                rctxtBx.AppendText(cc.getlog());
            }
            catch (Exception Ex)
            {
                Console.WriteLine("Error", Ex);
            }
        }
示例#9
0
        static void Main(string[] args)
        {
            Console.Write("\n  Demonstrating Project #4 Channel Prototype");
            Console.Write("\n ============================================\n");

            ChannelDemo <Client> demo1 = new ChannelDemo <Client>();

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

            string rcvrEndPoint1 = Comm <Server> .makeEndPoint("http://localhost", 8080);

            demo1.comm.rcvr.CreateRecvChannel(rcvrEndPoint1);
            Thread rcvThread1 = demo1.comm.rcvr.start(demo1.rcvThreadProc);

            Console.Write("\n  rcvr thread id = {0}", rcvThread1.ManagedThreadId);
            Console.WriteLine();

            ChannelDemo <Server> demo2 = new ChannelDemo <Server>();

            string sndrEndPoint2 = Comm <Client> .makeEndPoint("http://localhost", 8081);

            string rcvrEndPoint2 = Comm <Server> .makeEndPoint("http://localhost", 8081);

            demo2.comm.rcvr.CreateRecvChannel(rcvrEndPoint2);
            Thread rcvThread2 = demo2.comm.rcvr.start(demo2.rcvThreadProc);

            Console.Write("\n  rcvr thread id = {0}", rcvThread2.ManagedThreadId);
            Console.WriteLine();

            // make a TestRequest message and send five times to two different endpoints

            Message msg = null;
            string  rcvrEndPoint;

            for (int i = 0; i < 5; ++i)
            {
                msg      = new Message(demo1.makeTestRequest());
                msg.type = "TestRequest";
                msg.from = sndrEndPoint1;
                if (i < 3)
                {
                    msg.to = rcvrEndPoint = rcvrEndPoint1;
                }
                else
                {
                    msg.to = rcvrEndPoint = rcvrEndPoint2;
                }
                msg.author = "Fawcett";
                msg.time   = DateTime.Now;

                demo1.comm.sndr.PostMessage(msg);

                Console.Write("\n  {0}\n  posting message with body:\n{1}", msg.from, msg.body.shift());
                Thread.Sleep(20);
            }
            msg      = new Message();
            msg.from = sndrEndPoint1;
            msg.to   = rcvrEndPoint2;
            msg.body = "quit";

            demo1.comm.sndr.PostMessage(msg);
            rcvThread2.Join();
            Console.Write("\n  rcvThread1.state = {0}", rcvThread1.ThreadState.ToString());
            Console.Write("\n  rcvThread2.state = {0}", rcvThread2.ThreadState.ToString());
            msg      = new Message();
            msg.from = sndrEndPoint2;
            msg.to   = rcvrEndPoint1;
            msg.body = "quit";

            demo2.comm.sndr.PostMessage(msg);
            Thread.Sleep(500);
            Console.Write("\n  rcvThread1.state = {0}", rcvThread1.ThreadState.ToString());

            rcvThread1.Join();
            Console.Write("\n  passed 2nd Join");

            Console.Write("\n\n");
        }