예제 #1
0
파일: Main.cs 프로젝트: Gohla/protophase
        public static void Main(string[] args)
        {
            try {
                // Get console quit key press events.
                Console.CancelKeyPress += CancelKeyPressHandler;

                // Sleep so registry and server can start up first.
                Thread.Sleep(1000);

                // Create registry client for registry at address tcp://localhost:5555.
                using(Registry registry = new Registry())
                {
                    // Get HelloWorldResponder service, loop until it exists.
                    Service helloWorld1 = null;
                    while(helloWorld1 == null) helloWorld1 = registry.GetServiceByUID("HelloWorldResponder1");
                    Console.WriteLine("Found HelloWorldResponder1: " + helloWorld1);

                    // Get HelloWorldResponder services, loop until it exists.
                    Service helloWorldAll = null;
                    while(helloWorldAll == null) helloWorldAll = registry.GetServiceByType("HelloWorldResponder");
                    Console.WriteLine("Found HelloWorldResponders: " + helloWorldAll);

                    // Subscribe for published event.
                    helloWorld1.Published += (object obj) => Console.WriteLine("HelloWorldResponder1 published: " + obj);
                    helloWorldAll.Published += (object obj) => Console.WriteLine("HelloWorldResponders published: " + obj);

                    // Program loop
                    while(!_quit) {
                        // Call receive on the objects to receive published messages.
                        // TODO: Optionally let the library take care of this.
                        //helloWorld1.Receive();
                        //helloWorldAll.Receive();
                        registry.Update();
                        //Console.WriteLine(ApplicationInstance.Guid);

                        // RPC HelloWorld function with no parameters and print the result.
                        //Console.WriteLine("RPC call HelloWorld on HelloWorldResponder1: " + helloWorld1.Call<String>("HelloWorld"));
                        //Console.WriteLine("RPC call HelloWorld on HelloWorldResponders: " + helloWorldAll.Call<String>("HelloWorld"));
                        // RPC ReturnParam function with 3 params and print the result.
                        //Console.WriteLine("RPC call ReturnParam on HelloWorldResponder1: " + helloWorld1.Call<String>("ReturnParam", 1, 1.0f, "one"));
                        //Console.WriteLine("RPC call ReturnParam on HelloWorldResponders: " + helloWorldAll.Call<String>("ReturnParam", 1, 1.0f, "one"));

                        Thread.Sleep(100);
                    }

                    // Dispose of service objects to free sockets.
                    helloWorld1.Dispose();
                    helloWorldAll.Dispose();
                }
            } catch(Exception e) {
                Console.WriteLine(e.Message + "\n" + e.StackTrace);
                Thread.Sleep(10000);
            }
        }
예제 #2
0
 public void Start()
 {
     registry = new Registry();
     if (!registry.Register(this))
     {
         Console.WriteLine("Error registering service.");
         return;
     }
     Console.WriteLine("Registered service.");
     Service rawDataPublisher = null;
     while (rawDataPublisher == null && !quit)
         rawDataPublisher = registry.GetServiceByType("RawAisDataPublisher");
     if (!quit)
         rawDataPublisher.Published += RAWAisDataRecieved;
     while (!quit)
         registry.Update();
     registry.Unregister(this);
 }
예제 #3
0
파일: Program.cs 프로젝트: Gohla/protophase
 static void Main(string[] args)
 {
     registry = new Registry();
     Service rawDataPublisher = null;
     while (rawDataPublisher == null && !quit)
         rawDataPublisher = registry.GetServiceByType("RawAisDataPublisher");
     rawDataPublisher.Published += publishedEvent;
     while (!quit)
     {
         Console.Clear();
         Console.WriteLine("Total messages: " + TotalCount);
         Console.WriteLine("Total messages OK: " + OKCount);
         Console.WriteLine("Total messages Multipart: " + MultiPartCount);
         Console.WriteLine("Total messages Failed: " + FailCount);
         Console.WriteLine("");
         Console.WriteLine("Pecentage OK: " + (((double)OKCount / (double)TotalCount))*100);
         Thread.Sleep(100);
         registry.Update();
     }
 }
예제 #4
0
 static void Main(string[] args)
 {
     testKML = new GoogleEarthKMLDumper();
     Console.CancelKeyPress += CancelKeyPressHandler;
     Registry registry = new Registry();
     Service aisDataPublisher = null;
     while (aisDataPublisher == null && !quit)
         aisDataPublisher = registry.GetServiceByType("AisDataPublisher");
     aisDataPublisher.Published += publishedEvent;
     int count = 0;
     while (!quit)
     {
         count++;
         if (count > 10)
         {
             count = 0;
             testKML.DumpKMLFile();
         }
         registry.Update();
         Thread.Sleep(100);
     }
 }