Esempio n. 1
0
        public static void Main(string[] args)
        {
            var calculatorImp = new CalculatorImp();
            var dispatcherThread = new DispatcherThread(Dispatcher.Run);
            dispatcherThread.Start();

            var server = new IpcServer<ICalculator>(calculatorImp, dispatcherThread.Dispatcher, IPAddress.Loopback, 62001, new JsonDotNetSerializer());
            server.ClientConnected += OnClientConnected;
            server.ClientDisconnected += OnClientDisconnected;

            server.Listen();

            Console.WriteLine("Calculator service running, press any key to exit.");
            Console.ReadLine();

            server.ClientDisconnected -= OnClientDisconnected;
            server.ClientConnected -= OnClientConnected;

            server.Dispose();
            dispatcherThread.Shutdown();
        }
Esempio n. 2
0
        public static void Main(string[] args)
        {
            var calculatorImp    = new CalculatorImp();
            var dispatcherThread = new DispatcherThread(Dispatcher.Run);

            dispatcherThread.Start();

            var server = new IpcServer <ICalculator>(calculatorImp, dispatcherThread.Dispatcher, IPAddress.Loopback, 62001, new JsonDotNetSerializer());

            server.ClientConnected    += OnClientConnected;
            server.ClientDisconnected += OnClientDisconnected;

            server.Listen();

            Console.WriteLine("Calculator service running, press any key to exit.");
            Console.ReadLine();

            server.ClientDisconnected -= OnClientDisconnected;
            server.ClientConnected    -= OnClientConnected;

            server.Dispose();
            dispatcherThread.Shutdown();
        }
Esempio n. 3
0
        private static void Main(string[] args)
        {
            var calculatorImp = new CalculatorImp();
            var dispatcherThread = new DispatcherThread(Dispatcher.Run);
            dispatcherThread.Start();

            var server = new IpcServer<ICalculator>(calculatorImp, dispatcherThread.Dispatcher, IPAddress.Any, 62005, new JsonDotNetSerializer());
            server.ClientConnected += OnClientConnected;
            server.ClientDisconnected += OnClientDisconnected;

            server.Listen();

            var multiCastAddress = IPAddress.Parse("239.0.0.222");
            var advertiser = new ServiceAdvertiser<ICalculator>(multiCastAddress, 2222, TimeSpan.FromMilliseconds(1000));
            advertiser.OnAdvertisement += dt => Console.WriteLine("[{0}]", dt);

            Console.ReadLine();

            server.ClientDisconnected -= OnClientDisconnected;
            server.ClientConnected -= OnClientConnected;


            advertiser.Dispose();
        }