Ejemplo n.º 1
0
        public void SCNetworkControllerTest()
        {
            //WcfScServiceHost scnet = new WcfScServiceHost();

            DiscoveryClient discoveryClient = new DiscoveryClient(new UdpDiscoveryEndpoint());

            Collection <EndpointDiscoveryMetadata> helloWorldServices = discoveryClient.Find(new FindCriteria(typeof(IWcfScDataTransferService))).Endpoints;

            discoveryClient.Close();

            if (helloWorldServices.Count == 0)
            {
                Console.WriteLine("No services");
                return;
            }
            else
            {
                IWcfScDataTransferServiceCallback evnt = new MySubscriber();
                InstanceContext    evntCntx            = new InstanceContext(evnt);
                EventServiceClient proxy = new EventServiceClient(evntCntx);
                proxy.SubscribeAllConnectedEvent();
                string output = proxy.Connect(ConnectionClients.Controller);
                Console.WriteLine(output);

                //EndpointAddress serviceAddress = helloWorldServices[0].Address;

                //var binding = new NetTcpBinding();
                //var factory = new ChannelFactory<IWcfScDataTransferService>(binding);
                //IWcfScDataTransferService channel = factory.CreateChannel(serviceAddress);
                //string result = channel.SayHello("Unit Test John");
                //Console.WriteLine(result);
            }
        }