Esempio n. 1
0
        public static List <DeviceDiscoveryData> GetDevices(SoapMessage <WSD.ProbeMatchesType> message, Net.IPAddress sender)
        {
            List <DeviceDiscoveryData> devices = new List <DeviceDiscoveryData>();

            if (message.Object.ProbeMatch != null)
            {
                for (int i = 0; i < message.Object.ProbeMatch.Length; i++)
                {
                    WSD.ProbeMatchType match = message.Object.ProbeMatch[i];
                    if ((match.XAddrs != null) && (CheckDeviceMatchType(message, i)))
                    {
                        DeviceDiscoveryData device = new DeviceDiscoveryData();
                        device.Type            = match.Types;
                        device.Scopes          = match.Scopes.Text[0];
                        device.EndPointAddress = sender.ToString();

                        string[] addresses = match.XAddrs.Split(new char[] { ' ' }, StringSplitOptions.RemoveEmptyEntries);
                        device.ServiceAddresses.AddRange(addresses);
                        device.UUID            = match.EndpointReference.Address.Value;
                        device.MetadataVersion = match.MetadataVersion;
                        devices.Add(device);
                    }
                }
            }
            return(devices);
        }
Esempio n. 2
0
        public static List <DeviceDiscoveryData> GetDevices(
            SoapMessage <WSD.ProbeMatchesType> message, Net.IPAddress sender, DiscoveryType[][] types)
        {
            List <DeviceDiscoveryData> devices = new List <DeviceDiscoveryData>();

            if (message.Object.ProbeMatch != null)
            {
                for (int i = 0; i < message.Object.ProbeMatch.Length; i++)
                {
                    WSD.ProbeMatchType match = message.Object.ProbeMatch[i];
                    if ((match.XAddrs != null) &&
                        (types == null
                         //check devices according to Test Spec Annex A.1
                            ? CheckDeviceMatchType(message, i, true, false)
                         //check if device contains at least one item from types array
                            : CheckDeviceMatchType(message, i, types)))
                    {
                        DeviceDiscoveryData device = new DeviceDiscoveryData();
                        device.Type            = match.Types;
                        device.Scopes          = match.Scopes.Text[0];
                        device.EndPointAddress = sender.ToString();

                        string[] addresses = match.XAddrs.Split(new char[] { ' ' }, StringSplitOptions.RemoveEmptyEntries);
                        device.ServiceAddresses.AddRange(addresses);
                        device.UUID            = match.EndpointReference.Address.Value;
                        device.MetadataVersion = match.MetadataVersion;
                        devices.Add(device);
                    }
                }
            }
            return(devices);
        }