Exemple #1
0
        public void QueryTheRepoForAllLogs()
        {
            string author         = "Nikhil Prashar";
            string remoteEndPoint = Comm <Client> .makeEndPoint("http://localhost", 8080, "RepositoryServer");

            Message msg = makeMessage(author, endPoint, remoteEndPoint, "RetrieveAllLogs");

            msg.body = "Retrieve all logs";
            Console.WriteLine("\nClient sending message to Repository to Retrieve All The Logs: {0} ------> Requirement Number 9(Reference: Client.cs line number 138-144)", msg.ToString());
            comm.sndr.PostMessage(msg);
        }
Exemple #2
0
        //----< run client demo >----------------------------------------
        private void RetrieveLogsButton_Click(object sender, RoutedEventArgs e)
        {
            string author         = "Nikhil Prashar";
            string remoteEndPoint = Comm <WPFClient1> .makeEndPoint("http://localhost", 8080, "RepositoryServer");

            Message msg = makeMessage(author, endPoint, remoteEndPoint, "RetrieveAllLogs");

            msg.body = "Retrieve all logs";
            Console.WriteLine("\nClient sending message to Repository: {0}", msg.ToString());
            comm.sndr.PostMessage(msg);
        }
Exemple #3
0
        //----< send message to connected listener >---------------------
        private void SendMessageButton_Click(object sender, RoutedEventArgs e)
        {
            string author1        = "Nikhil Prashar";
            string remoteEndPoint = Comm <WPFClient1> .makeEndPoint("http://localhost", 8080, "TestHarnessServer");

            Message msg = makeMessage(author1, endPoint, remoteEndPoint, "TestRequest");

            msg.body = MessageTest.makeTestRequest(author1);
            Parser p = new Parser();

            TestRequest       tr   = p.parse(msg.body);
            ClientFileManager cfm  = new ClientFileManager();
            List <string>     dlls = cfm.RetrieveFilesFromRepo(tr);

            int          count = 0;
            IFileService fs    = null;

            while (true)
            {
                try
                {
                    fs = CreateChannelForFileTransfer("http://localhost:8080/RepositoryServer");
                    break;
                }
                catch
                {
                    Console.Write("\n  connection to Test Harness service failed {0} times - trying again", ++count);
                    Thread.Sleep(500);
                    continue;
                }
            }

            foreach (string file in dlls)
            {
                string filename = System.IO.Path.GetFileName(file);
                Console.Write("\n  sending file {0}", filename);

                if (!SendFile(fs, file))
                {
                    Console.Write("\n  could not send file");
                }
            }


            Console.WriteLine("\nClient sending message: {0}", msg.ToString());
            comm.sndr.PostMessage(msg);

            this.Dispatcher.BeginInvoke(
                System.Windows.Threading.DispatcherPriority.Normal,
                SentNewMessage,
                msg.body);
        }
        static void Main(string[] args)
        {
            Console.WriteLine("\t\t\tClient 2");
            Console.WriteLine("=======================================================================\n\n");


            Client2 client         = new Client2();
            string  author1        = "Pranjul Arora";
            string  remoteEndPoint = Comm <Client2> .makeEndPoint("http://localhost", 8080, "TestHarnessServer");

            Message msg = client.makeMessage(author1, client.endPoint, remoteEndPoint, "TestRequest");

            msg.body = makeTestRequest(author1);
            Console.WriteLine();
            "Demonstrating Requirement Number 2".title('-');
            Console.WriteLine("\n\tMessage Created at Client to be sent to the Test Harness\n{0}", msg.ToString());

            client.SendingDllsToRepository(msg); //Sending Dlls to the repo

            resultArrived = false;
            client.comm.sndr.PostMessage(msg);  //Sending test request message to the Test Harness

            Console.WriteLine("\n\tTest Request Sent To the Test Harness Server -------> Requirement 6(Reference: Client.cs Line Number 146");
            Console.WriteLine("\n\tReference: Client Project, Line number 110-148");
            Console.WriteLine("\n-----------------------------------------------\n");

            while (true)
            {
                if (resultArrived)
                {
                    Thread.Sleep(2000);
                    client.QueryTheRepoForAllLogs(); //Quering the repo for all logs
                    break;
                }
            }

            Console.ReadKey();
            msg.to   = client.endPoint;
            msg.body = "quit";
            client.comm.sndr.PostMessage(msg);
            client.wait();
            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");
        }
        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");
        }