Exemplo n.º 1
0
        protected void OnMessageReceived(object sender, DiscoveryMessageEventArgs e)
        {
            TestMessages TestMessage = new TestMessages();
            string       message     = e.Message;

            message = message.Replace('\n', ' ');
            message = message.Replace('\r', ' ');
            message = message.Replace('\t', ' ');
            message = message.Replace("                ", " ");
            message = message.Replace("        ", " ");
            message = message.Replace("    ", " ");
            message = message.Replace("  ", " ");
            message = message.Replace("> <", "><");
            message = message.Replace(">  <", "><");

            try
            {
                RD.ProbeMatchesType match  = (RD.ProbeMatchesType)TestMessage.Parse_SoapMessage(message, typeof(RD.ProbeMatchesType));
                DeviceDiscovered    device = GetDevice(match, e.Source.Address);
                if (device != null)
                {
                    DeviceDiscoveryEventArgs args = new DeviceDiscoveryEventArgs(device);
                    if (Discovered != null)
                    {
                        Discovered(this, args);
                    }
                }
            }
            catch
            {
            }
        }
Exemplo n.º 2
0
        protected DeviceDiscovered GetDevice(RD.ProbeMatchesType match, IPAddress from)
        {
            DeviceDiscovered res = null;

            if ((match.ProbeMatch != null) && (match.ProbeMatch.Length > 0) && (match.ProbeMatch[0].XAddrs != null))
            {
                // this is a problem since this is a required field
                // tell the user there was an error on the device but don't
                // add it to the list
                if (match.ProbeMatch[0].Types == "dn:NetworkVideoTransmitter")
                {
                    res                = new DeviceDiscovered();
                    res.Type           = match.ProbeMatch[0].Types;
                    res.Scopes         = match.ProbeMatch[0].Scopes.Text[0];
                    res.IP             = from.ToString();
                    res.ServiceAddress = match.ProbeMatch[0].XAddrs;
                    res.UUID           = match.ProbeMatch[0].EndpointReference.Address.Value;
                    res.Metadata       = match.ProbeMatch[0].MetadataVersion;
                }
            }
            return(res);
        }