コード例 #1
0
ファイル: Program.cs プロジェクト: sk8tz/RSSDP
        private static void PublishDevices()
        {
            if (_DevicePublisher != null)
            {
                Console.WriteLine("Stopping previous publisher.");
                _DevicePublisher.Dispose();
            }

            // Create a device publisher
            _DevicePublisher = new SsdpDevicePublisher();

            // Create the device(s) we want to publish.
            var rootDevice = new SsdpRootDevice()
            {
                CacheLifetime = TimeSpan.FromMinutes(30),
                FriendlyName  = "Sample RSSDP Device",
                Manufacturer  = "RSSDP",
                ModelNumber   = "123",
                ModelName     = "RSSDP Sample Device",
                SerialNumber  = "123",
                Uuid          = System.Guid.NewGuid().ToString()
            };

            rootDevice.CustomResponseHeaders.Add(new CustomHttpHeader("X-MachineName", Environment.MachineName));

            // Now publish by adding them to the publisher.
            _DevicePublisher.AddDevice(rootDevice);

            Console.WriteLine("Publishing devices: ");
            WriteOutDevices(rootDevice);
            Console.WriteLine();
        }
コード例 #2
0
 public void DisposeDevicePublisher()
 {
     if (_Publisher != null)
     {
         _logger.LogInformation("Disposing SsdpDevicePublisher");
         _Publisher.Dispose();
         _Publisher = null;
     }
 }
コード例 #3
0
ファイル: DlnaEntryPoint.cs プロジェクト: yester/Emby
        public void DisposeDlnaServer()
        {
            if (_Publisher != null)
            {
                _Publisher.Dispose();
            }

            _dlnaServerStarted = false;
        }
コード例 #4
0
        private static void PublishDevices()
        {
            if (_DevicePublisher != null)
            {
                Console.WriteLine("Stopping previous publisher.");
                _DevicePublisher.Dispose();
            }

            // Create a device publisher
            _DevicePublisher = new SsdpDevicePublisher();

            // Create the device(s) we want to publish.
            var rootDevice = new SsdpRootDevice()
            {
                CacheLifetime = TimeSpan.FromMinutes(30),
                FriendlyName  = "Sample RSSDP Device",
                Manufacturer  = "RSSDP",
                ModelNumber   = "123",
                ModelName     = "RSSDP Sample Device",
                SerialNumber  = "123",
                Uuid          = System.Guid.NewGuid().ToString()
            };

            rootDevice.CustomResponseHeaders.Add(new CustomHttpHeader("X-MachineName", Environment.MachineName));

            var service = new SsdpService()
            {
                Uuid                 = System.Guid.NewGuid().ToString(),
                ServiceType          = "test-service-type",
                ServiceTypeNamespace = "rssdp-test-namespace",
                ControlUrl           = new Uri("/test/control", UriKind.Relative),
                EventSubUrl          = new Uri("/test/event", UriKind.Relative),
                ScpdUrl              = new Uri("/test", UriKind.Relative)
            };

            rootDevice.AddService(service);

            // Now publish by adding them to the publisher.
            _DevicePublisher.AddDevice(rootDevice);

            Console.WriteLine("Publishing devices: ");
            WriteOutDevices(rootDevice);
            Console.WriteLine();
        }
コード例 #5
0
        public void DisposeDlnaServer()
        {
            if (_Publisher != null)
            {
                var devices = _Publisher.Devices.ToList();
                var tasks   = devices.Select(i => _Publisher.RemoveDevice(i)).ToArray();

                Task.WaitAll(tasks);
                //foreach (var device in devices)
                //{
                //    try
                //    {
                //        _Publisher.RemoveDevice(device);
                //    }
                //    catch (Exception ex)
                //    {
                //        _logger.ErrorException("Error sending bye bye", ex);
                //    }
                //}
                _Publisher.Dispose();
            }

            _dlnaServerStarted = false;
        }
コード例 #6
0
 public void Dispose()
 {
     _httpClient.Dispose();
     _publisher.Dispose();
 }
コード例 #7
0
        private static void PublishDevices()
        {
            if (_DevicePublisher != null)
            {
                Console.WriteLine("Stopping previous publisher.");
                _DevicePublisher.Dispose();
            }

            if (_HttpServer != null)
            {
                _HttpServer.Close();
            }

            // Create a device publisher
            _DevicePublisher = new SsdpDevicePublisher();

            //These settings make RSSDP play nicely with Windows Explorer
            //and some badly behaved clients.
            _DevicePublisher.StandardsMode = SsdpStandardsMode.Relaxed;

            // Create the device(s) we want to publish.
            var url = new Uri("http://" + Environment.MachineName + ":8181/");

            var rootDevice = new SsdpRootDevice()
            {
                CacheLifetime    = TimeSpan.FromMinutes(30),
                FriendlyName     = "Sample RSSDP Device",
                Manufacturer     = "RSSDP",
                ModelNumber      = "123",
                ModelName        = "RSSDP Sample Device",
                ModelDescription = "Test Device from RSSDP Console App",
                ManufacturerUrl  = new Uri("https://github.com/Yortw/RSSDP"),
                SerialNumber     = "123",
                Uuid             = System.Guid.NewGuid().ToString(),
                UrlBase          = url
            };

            rootDevice.CustomResponseHeaders.Add(new CustomHttpHeader("X-MachineName", Environment.MachineName));

            var service = new SsdpService()
            {
                Uuid                 = System.Guid.NewGuid().ToString(),
                ServiceType          = "test-service-type",
                ServiceTypeNamespace = "rssdp-test-namespace",
                ControlUrl           = new Uri("/test/control", UriKind.Relative),
                EventSubUrl          = new Uri("/test/event", UriKind.Relative),
                ScpdUrl              = new Uri("/test", UriKind.Relative)
            };

            rootDevice.AddService(service);

            rootDevice.Location = new Uri(url, "ddd");

            //Some 3rd party tools won't show the device unless they can get
            //the device description document, so this sample uses a really simple HTTP
            //server just to serve that.
            StartHttpServerForDdd(rootDevice, url);

            // Now publish by adding them to the publisher.
            _DevicePublisher.AddDevice(rootDevice);

            Console.WriteLine("Publishing devices: ");
            WriteOutDevices(rootDevice);
            Console.WriteLine();
        }