Esempio n. 1
0
        void AnnounceDevice(Device device)
        {
            ssdp_server.Announce(device.Udn, device.Udn, false);
            ssdp_server.Announce(device.Type.ToString(), string.Format("{0}::{1}", device.Udn, device.Type), false);

            foreach (var child_device in device.Devices)
            {
                AnnounceDevice(child_device);
            }

            foreach (var service in device.Services)
            {
                AnnounceService(device, service);
            }
        }
Esempio n. 2
0
        private static void StartSsdp()
        {
            try {
                string BindAddress = Dns.GetHostName();

                IPAddress   ip  = null;
                IPAddress[] ips = Dns.GetHostAddresses(BindAddress);

                // Try to send an IPv4 address
                foreach (var i in ips)
                {
                    if (i.AddressFamily == System.Net.Sockets.AddressFamily.InterNetwork)
                    {
                        ip = i;
                        break;
                    }
                }

                if (ip == null)
                {
                    ip = ips[0];
                }

                // Start the announce server
                ssdp_service = new Mono.Ssdp.Server();

                string location = string.Format("{0}|{1}|{2}|{3}|{4}", Dns.GetHostName(), ip.ToString(), port, Platform.GetPlatformString(), Platform.GetCapabilities());
                ssdp_service.Announce("mono-vs", Guid.NewGuid().ToString(), location);
            } catch {
                Logger.LogInfo("Could not start Ssdp, automatic server detection will be disabled.");
            }
        }
Esempio n. 3
0
        private void AnnounceDevice(Device device)
        {
            ssdp_server.Announce(device.Udn, device.Udn, false);
            ssdp_server.Announce(device.Type.ToString(), String.Format("{0}::{1}", device.Udn, device.Type), false);

            if (device.Devices != null)
            {
                foreach (Device d in device.Devices)
                {
                    AnnounceDevice(d);
                }
            }

            if (device.Services != null)
            {
                foreach (ServiceDescription service in device.Services)
                {
                    AnnounceService(device, service);
                }
            }
        }
Esempio n. 4
0
 public Server (Root root, Uri url)
 {
     if (root == null) {
         throw new ArgumentNullException ("root");
     }
     
     this.root = root;
     
     if (url == null) {
         url = MakeUrl ();
     }
     
     var serializer = Helper.Get<XmlSerializer> (static_serializer);
     root.Initialize (serializer, url);
     // FIXME this is a test
     description_server = new DataServer (serializer.GetBytes (root), @"text/xml", url);
     ssdp_server = new SsdpServer (url.ToString ());
     ssdp_server.Announce ("upnp:rootdevice", root.RootDevice.Udn + "::upnp:rootdevice", false);
     AnnounceDevice (root.RootDevice);
 }
Esempio n. 5
0
        public Server(Root root, Uri url)
        {
            if (root == null)
            {
                throw new ArgumentNullException("root");
            }

            this.root = root;

            if (url == null)
            {
                url = MakeUrl();
            }

            var serializer = Helper.Get <XmlSerializer> (static_serializer);

            root.Initialize(serializer, url);
            // FIXME this is a test
            description_server = new DataServer(serializer.GetBytes(root), @"text/xml", url);
            ssdp_server        = new SsdpServer(url.ToString());
            ssdp_server.Announce("upnp:rootdevice", root.RootDevice.Udn + "::upnp:rootdevice", false);
            AnnounceDevice(root.RootDevice);
        }
Esempio n. 6
0
 private void Announce()
 {
     ssdp_server = new SsdpServer(description_server.Url.ToString());
     ssdp_server.Announce("upnp:rootdevice", root_device.Udn + "::upnp:rootdevice", false);
     AnnounceDevice(root_device);
 }
Esempio n. 7
0
 private void Announce()
 {
     ssdp_server = new SsdpServer (description_server.Url.ToString ());
     ssdp_server.Announce ("upnp:rootdevice", root_device.Udn + "::upnp:rootdevice", false);
     AnnounceDevice (root_device);
 }