コード例 #1
0
        //----< 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);
        }
コード例 #2
0
ファイル: Client.cs プロジェクト: KavishPahade/Document_Vault
 public void category_click(string contents, string resourcename)
 {
     EchoCommunicator echo = new EchoCommunicator();
           echo.Name = "client-echo";
           receiver.Register(echo);
           echo.Start();
           ServiceMessage msg1 =
           ServiceMessage.MakeMessage("echo", "ServiceClient", contents, resourcename);
           msg1.SourceUrl = ClientUrl;
           msg1.TargetUrl = ServerUrl;
           //Console.Write("\n  Posting message to \"{0}\" component", msg1.TargetCommunicator);
           sender.PostMessage(msg1);
           receiver.Close();
           Console.Write("\n\n");
 }
コード例 #3
0
        static void Main(string[] args)
        {
            Console.Write("\n  Starting CommService");
            Console.Write("\n ======================\n");

            string   ServerUrl = "http://localhost:8000/CommService";
            Receiver receiver  = new Receiver(ServerUrl);

            EchoCommunicator echo = new EchoCommunicator();

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

            string ClientUrl = echo.GetClientUrl();
            Sender sender    = new Sender();

            sender.Name = "sender";
            sender.Connect(ClientUrl);
            receiver.Register(sender);
            sender.Start();


            QueryCommunicator query = new QueryCommunicator();

            query.Name = "query";
            receiver.Register(query);
            query.Start();

            // parent/child relationships

            NavigationCommunicator nav = new NavigationCommunicator();

            nav.Name = "nav";
            receiver.Register(nav);
            nav.Start();

            Console.Write("\n  Started CommService - Press key to exit:\n ");
            Console.ReadKey();
        }
コード例 #4
0
            static void Main(string[] args)
            {
                Console.Write("\n  Starting CommService");
                Console.Write("\n ======================\n");

                string   ServerUrl = "http://localhost:8000/CommService";
                Receiver receiver  = new Receiver(ServerUrl);

                string ClientUrl = "http://localhost:8001/CommService";

                Sender sender = new Sender();

                sender.Name = "sender";
                sender.Connect(ClientUrl);
                receiver.Register(sender);
                sender.Start();

                // Test Component that simply echos message

                EchoCommunicator echo = new EchoCommunicator();

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

                // Placeholder for query processor

                QueryCommunicator query = new QueryCommunicator();

                query.Name = "query";
                receiver.Register(query);
                query.Start();

                FileContent filecontent = new FileContent();

                filecontent.Name = "filecontent";
                receiver.Register(filecontent);
                filecontent.Start();

                EditMetadataCommunicator editmetadata = new EditMetadataCommunicator();

                editmetadata.Name = "metadataedit";
                receiver.Register(editmetadata);
                editmetadata.Start();
                // Placeholder for component that searches for and returns
                // parent/child relationships

                TextFilesCommunicator textfiles = new TextFilesCommunicator();

                textfiles.Name = "textfiles";
                receiver.Register(textfiles);
                textfiles.Start();

                NavigationCommunicator nav = new NavigationCommunicator();

                nav.Name = "nav";
                receiver.Register(nav);
                nav.Start();

                FileInsertionCommunicator fic = new FileInsertionCommunicator();

                fic.Name = "file";
                receiver.Register(fic);
                fic.Start();

                Console.Write("\n  Started CommService - Press key to exit:\n ");
                Console.ReadKey();
            }
コード例 #5
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");
        }