//----< register with Server>----------------
        public void ClientStart()
        {
            ServerUrl = "http://localhost:8000/CommService";
            sender    = null;
            sender    = new Sender();
            sender.Connect(ServerUrl);
            sender.Start();

            reference.dispatcher.BeginInvoke(new invoker(GetClientUrl),
                                             System.Windows.Threading.DispatcherPriority.Send);
            receiver = new Receiver(ClientUrl);

            EchoCommunicator echo = new EchoCommunicator(reference);

            echo.Name = "client-echo";
            receiver.Register(echo);
            echo.Start();

            NaviCommnuicator nav = new NaviCommnuicator(reference);

            nav.Name = "client-nav";
            receiver.Register(nav);
            nav.Start();
            ServiceMessage msg =
                ServiceMessage.MakeMessage("echo", "ServiceClient", "connect to server", ClientUrl);

            msg.SourceUrl = ClientUrl;
            msg.TargetUrl = ServerUrl;
            sender.PostMessage(msg);
        }
        //----< get categories and files in Server>----------------
        public void GetContent()
        {
            ServiceMessage msg1 =
                ServiceMessage.MakeMessage("echo", "ServiceClient", "get category", "category");

            msg1.SourceUrl = ClientUrl;
            msg1.TargetUrl = ServerUrl;
            sender.PostMessage(msg1);

            ServiceMessage msg2 =
                ServiceMessage.MakeMessage("nav", "ServiceClient", "mapping", "get pc relationship");

            msg2.SourceUrl = ClientUrl;
            msg2.TargetUrl = ServerUrl;
            sender.PostMessage(msg2);
        }
Example #3
0
        static void Main(string[] args)
        {
            Console.Write("\n  Starting CommService Client");
            Console.Write("\n =============================\n");

            string ServerUrl = "http://localhost:8000/CommService";
            Sender sender    = null;

            Console.Write("\n  Press key to start client: ");
            Console.ReadKey();

            sender = new Sender();
            sender.Connect(ServerUrl);
            sender.Start();

            string   ClientUrl = "http://localhost:8001/CommService";
            Receiver receiver  = new Receiver(ClientUrl);

            // Don't need to start receiver unless you want
            // to send it messages, which we won't as all
            // our messages go to the server
            //receiver.Start();

            EchoCommunicator echo = new EchoCommunicator();

            echo.Name = "client-echo";
            receiver.Register(echo);
            echo.Start();

            ServiceMessage msg1 =
                ServiceMessage.MakeMessage("echo", "ServiceClient", "<root>some echo stuff</root>", "no name");

            msg1.SourceUrl = ClientUrl;
            msg1.TargetUrl = ServerUrl;
            Console.Write("\n  Posting message to \"{0}\" component", msg1.TargetCommunicator);
            sender.PostMessage(msg1);

            ServiceMessage msg2 =
                ServiceMessage.MakeMessage("query", "ServiceClient", "<root>some query stuff</root>", "no name");

            msg2.SourceUrl = ClientUrl;
            msg2.TargetUrl = ServerUrl;
            Console.Write("\n  Posting message to \"{0}\" component", msg2.TargetCommunicator);
            sender.PostMessage(msg2);

            ServiceMessage msg3 =
                ServiceMessage.MakeMessage("nav", "ServiceClient", "<root>some nav stuff</root>", "no name");

            msg3.SourceUrl = ClientUrl;
            msg3.TargetUrl = ServerUrl;
            Console.Write("\n  Posting message to \"{0}\" component", msg3.TargetCommunicator);
            sender.PostMessage(msg3);

            // wait for all server replies to be sent back

            Console.Write("\n  Wait for Server replies, then press a key to exit: ");
            Console.ReadKey();

            sender.Stop(); // this function sends a quit message to client-echo
            sender.Wait();
            echo.Stop();
            echo.Wait();
            receiver.Close();
            Console.Write("\n\n");
        }