Пример #1
0
 IEnumerable <DiscoveryDevice> CreateDevices(XmlProbeReponse response, IPEndPoint remoteEndpoint)
 {
     foreach (var probeMatch in response.Body.ProbeMatches)
     {
         var discoveryDevice = new DiscoveryDevice();
         discoveryDevice.Address   = remoteEndpoint.Address;
         discoveryDevice.XAdresses = ConvertToList(probeMatch.XAddrs);
         discoveryDevice.Types     = ConvertToList(probeMatch.Types);
         discoveryDevice.Model     = ParseModelFromScopes(probeMatch.Scopes);
         discoveryDevice.Name      = ParseNameFromScopes(probeMatch.Scopes);
         yield return(discoveryDevice);
     }
 }
Пример #2
0
 IEnumerable <DiscoveryDevice> ProcessResponses(IEnumerable <UdpReceiveResult> responses)
 {
     foreach (var response in responses)
     {
         if (response.Buffer != null)
         {
             string          strResponse = Encoding.UTF8.GetString(response.Buffer);
             XmlProbeReponse xmlResponse = DeserializeResponse(strResponse);
             foreach (var device in CreateDevices(xmlResponse, response.RemoteEndPoint))
             {
                 yield return(device);
             }
         }
     }
 }
Пример #3
0
        DiscoveryDevice CreateDevice(XmlProbeReponse response, IPEndPoint remoteEndpoint)
        {
            var    discoveryDevice = new DiscoveryDevice();
            string scopes          = response.Body.ProbeMatches[0].Scopes;

            discoveryDevice.Address = remoteEndpoint.Address.ToString();
            discoveryDevice.Model   = Regex.Match(scopes, "(?<=hardware/).*?(?= )").Value;
            discoveryDevice.Mac     = GetMacAddress(discoveryDevice.Address);
            discoveryDevice.Mfr     = ParseMfrFromScopes(scopes);
            string xaddr = response.Body.ProbeMatches[0].XAddrs;
            Uri    uri   = new Uri(xaddr);

            discoveryDevice.Port = uri.Port;
            return(discoveryDevice);
        }
Пример #4
0
 DiscoveryDevice ProcessResponse(UdpReceiveResult response, Guid messageId)
 {
     if (response.Buffer != null)
     {
         string          strResponse = Encoding.UTF8.GetString(response.Buffer);
         XmlProbeReponse xmlResponse = DeserializeResponse(strResponse);
         if (IsFromProbeMessage(messageId, xmlResponse) &&
             xmlResponse.Body.ProbeMatches.Any() &&
             !string.IsNullOrEmpty(xmlResponse.Body.ProbeMatches[0].Scopes))
         {
             return(CreateDevice(xmlResponse.Body.ProbeMatches[0], response.RemoteEndPoint));
         }
     }
     return(null);
 }
Пример #5
0
        List <DiscoveryDevice> ProcessResponses(IEnumerable <UdpReceiveResult> responses)
        {
            var processedResponse = new List <DiscoveryDevice> ();

            foreach (var response in responses)
            {
                if (response.Buffer != null)
                {
                    string          strResponse = Encoding.UTF8.GetString(response.Buffer);
                    XmlProbeReponse xmlResponse = DeserializeResponse(strResponse);
                    if (!String.IsNullOrEmpty(xmlResponse.Body.ProbeMatches[0].Scopes))
                    {
                        processedResponse.Add(CreateDevice(xmlResponse, response.RemoteEndPoint));
                    }
                }
            }
            return(processedResponse);
        }
Пример #6
0
        IEnumerable <DiscoveryDevice> ProcessResponses(IEnumerable <UdpReceiveResult> responses, Guid messageId)
        {
            var processedResponse = new List <DiscoveryDevice> ();

            foreach (var response in responses)
            {
                if (response.Buffer != null)
                {
                    string          strResponse = Encoding.UTF8.GetString(response.Buffer);
                    XmlProbeReponse xmlResponse = DeserializeResponse(strResponse);
                    if (IsFromProbeMessage(messageId, xmlResponse) &&
                        xmlResponse.Body.ProbeMatches.Any() &&
                        !string.IsNullOrEmpty(xmlResponse.Body.ProbeMatches[0].Scopes))
                    {
                        var device = CreateDevice(xmlResponse.Body.ProbeMatches[0], response.RemoteEndPoint);
                        processedResponse.Add(device);
                    }
                }
            }
            return(processedResponse);
        }
Пример #7
0
 bool IsFromProbeMessage(Guid messageId, XmlProbeReponse response)
 {
     return(response.Header.RelatesTo.Contains(messageId.ToString()));
 }