Exemple #1
0
        public static void Main(string[] args)
        {
            var uri = new Uri("net.tcp://localhost");
            var binding = new NetTcpBinding();
            var host = new ServiceHost(typeof(InformationService), uri);
            host.AddServiceEndpoint(typeof(IInformationService), binding, "");
            host.Open();

            for (int i = 0; i < 2; i++)
            {

                    new Thread((z) =>
                    {
                        var callback = new InformationServiceListener();
                        var channel = DuplexChannelFactory<IInformationService>.CreateChannel(callback, binding, new EndpointAddress(uri));

                        channel.Subscribe();

                    }).Start(i);

            }
            var _callback = new InformationServiceListener(2);
            var client = new SampleObservable(_callback, binding, new EndpointAddress(uri));
            var proxy = client.ChannelFactory.CreateChannel();
            proxy.Subscribe();
            new Thread(() => { while (true) { Thread.Sleep(1000); } });
            client.Close();
            Thread.CurrentThread.Join();
            // Printed in console:
            //  Hi from server!
            //  Hi from client!

            client.Close();
            host.Close();
        }
Exemple #2
0
 public Sample(SampleObservable <T> parent, IObserver <T> observer, IDisposable cancel) : base(observer, cancel)
 {
     this.parent = parent;
 }
 public Unsubscriber(SampleObservable <T> source, IObserver <T> observer)
 {
     _source   = source;
     _observer = observer;
 }