Ejemplo n.º 1
0
        }//Feito

        public override void Close()
        {
            try
            {
                player.Close();
            }
            catch
            {
            }
        } //Feito
Ejemplo n.º 2
0
        } //Feito

        public override IEnumerable <PlayerPC> GetPlayers()
        {
            List <WCFPlayerPC> pcs = new List <WCFPlayerPC>();

            Uri probeEndpointAddress = new Uri(CompleteServerAddress);

            NetTcpBinding binding = new NetTcpBinding();

            binding.Security.Mode = SecurityMode.None;
            binding.Security.Transport.ProtectionLevel = System.Net.Security.ProtectionLevel.None;

            DiscoveryEndpoint discoveryEndpoint = new DiscoveryEndpoint(binding, new EndpointAddress(probeEndpointAddress));

            DiscoveryClient discoveryClient = new DiscoveryClient(discoveryEndpoint);

            try
            {
                FindResponse findResponse = discoveryClient.Find(new FindCriteria(typeof(IPlayer)));

                WCFPlayerPC pc;

                foreach (var endpoint in findResponse.Endpoints)
                {
                    try
                    {
                        NetTcpBinding bindingPC = new NetTcpBinding();
                        binding.Security.Mode = SecurityMode.None;
                        binding.Security.Transport.ProtectionLevel = System.Net.Security.ProtectionLevel.None;

                        PlayerProxy client = new PlayerProxy(binding, endpoint.Address);

                        client.Open();

                        List <WCFScreenInformation> displays = client.GetDisplayInformation().ToList <WCFScreenInformation>();

                        client.Close();

                        pc = new WCFPlayerPC()
                        {
                            Displays = displays, Endpoint = endpoint.Address
                        };

                        pcs.Add(pc);
                    }
                    catch (EndpointNotFoundException)
                    {
                        continue;
                    }
                }
            }
            catch
            {
                return(null);
            }

            return(pcs.Cast <PlayerPC>());
        } //Feito