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(); }
public void DisposeDevicePublisher() { if (_Publisher != null) { _logger.LogInformation("Disposing SsdpDevicePublisher"); _Publisher.Dispose(); _Publisher = null; } }
public void DisposeDlnaServer() { if (_Publisher != null) { _Publisher.Dispose(); } _dlnaServerStarted = false; }
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(); }
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; }
public void Dispose() { _httpClient.Dispose(); _publisher.Dispose(); }
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(); }