|
|
|
@ -212,7 +212,9 @@ namespace MediaBrowser.Dlna.Ssdp
|
|
|
|
|
|
|
|
|
|
private void RespondToSearch(EndPoint endpoint, string deviceType)
|
|
|
|
|
{
|
|
|
|
|
if (_config.GetDlnaConfiguration().EnableDebugLogging)
|
|
|
|
|
var enableDebugLogging = _config.GetDlnaConfiguration().EnableDebugLogging;
|
|
|
|
|
|
|
|
|
|
if (enableDebugLogging)
|
|
|
|
|
{
|
|
|
|
|
_logger.Debug("RespondToSearch");
|
|
|
|
|
}
|
|
|
|
@ -238,7 +240,7 @@ namespace MediaBrowser.Dlna.Ssdp
|
|
|
|
|
SendDatagram(header, values, endpoint, new IPEndPoint(d.Address, 0), true, 1);
|
|
|
|
|
//SendDatagram(header, values, endpoint, null, true);
|
|
|
|
|
|
|
|
|
|
if (_config.GetDlnaConfiguration().EnableDebugLogging)
|
|
|
|
|
if (enableDebugLogging)
|
|
|
|
|
{
|
|
|
|
|
_logger.Debug("{1} - Responded to a {0} request to {2}", d.Type, endpoint, d.Address.ToString());
|
|
|
|
|
}
|
|
|
|
@ -316,7 +318,9 @@ namespace MediaBrowser.Dlna.Ssdp
|
|
|
|
|
|
|
|
|
|
var received = (byte[])result.AsyncState;
|
|
|
|
|
|
|
|
|
|
if (_config.GetDlnaConfiguration().EnableDebugLogging)
|
|
|
|
|
var enableDebugLogging = _config.GetDlnaConfiguration().EnableDebugLogging;
|
|
|
|
|
|
|
|
|
|
if (enableDebugLogging)
|
|
|
|
|
{
|
|
|
|
|
_logger.Debug(Encoding.ASCII.GetString(received));
|
|
|
|
|
}
|
|
|
|
@ -324,7 +328,7 @@ namespace MediaBrowser.Dlna.Ssdp
|
|
|
|
|
var args = SsdpHelper.ParseSsdpResponse(received);
|
|
|
|
|
args.EndPoint = endpoint;
|
|
|
|
|
|
|
|
|
|
if (_config.GetDlnaConfiguration().EnableDebugLogging)
|
|
|
|
|
if (enableDebugLogging)
|
|
|
|
|
{
|
|
|
|
|
var headerTexts = args.Headers.Select(i => string.Format("{0}={1}", i.Key, i.Value));
|
|
|
|
|
var headerText = string.Join(",", headerTexts.ToArray());
|
|
|
|
@ -399,17 +403,19 @@ namespace MediaBrowser.Dlna.Ssdp
|
|
|
|
|
|
|
|
|
|
private void NotifyAll()
|
|
|
|
|
{
|
|
|
|
|
if (_config.GetDlnaConfiguration().EnableDebugLogging)
|
|
|
|
|
var enableDebugLogging = _config.GetDlnaConfiguration().EnableDebugLogging;
|
|
|
|
|
|
|
|
|
|
if (enableDebugLogging)
|
|
|
|
|
{
|
|
|
|
|
_logger.Debug("Sending alive notifications");
|
|
|
|
|
}
|
|
|
|
|
foreach (var d in RegisteredDevices)
|
|
|
|
|
{
|
|
|
|
|
NotifyDevice(d, "alive", 1);
|
|
|
|
|
NotifyDevice(d, "alive", 1, enableDebugLogging);
|
|
|
|
|
}
|
|
|
|
|
}
|
|
|
|
|
|
|
|
|
|
private void NotifyDevice(UpnpDevice dev, string type, int sendCount)
|
|
|
|
|
private void NotifyDevice(UpnpDevice dev, string type, int sendCount, bool logMessage)
|
|
|
|
|
{
|
|
|
|
|
const string header = "NOTIFY * HTTP/1.1";
|
|
|
|
|
|
|
|
|
@ -424,7 +430,7 @@ namespace MediaBrowser.Dlna.Ssdp
|
|
|
|
|
values["NT"] = dev.Type;
|
|
|
|
|
values["USN"] = dev.USN;
|
|
|
|
|
|
|
|
|
|
if (_config.GetDlnaConfiguration().EnableDebugLogging)
|
|
|
|
|
if (logMessage)
|
|
|
|
|
{
|
|
|
|
|
_logger.Debug("{0} said {1}", dev.USN, type);
|
|
|
|
|
}
|
|
|
|
@ -457,7 +463,7 @@ namespace MediaBrowser.Dlna.Ssdp
|
|
|
|
|
|
|
|
|
|
foreach (var d in dl.ToList())
|
|
|
|
|
{
|
|
|
|
|
NotifyDevice(d, "byebye", 2);
|
|
|
|
|
NotifyDevice(d, "byebye", 2, true);
|
|
|
|
|
}
|
|
|
|
|
|
|
|
|
|
_logger.Debug("Unregistered mount {0}", uuid);
|
|
|
|
@ -468,13 +474,15 @@ namespace MediaBrowser.Dlna.Ssdp
|
|
|
|
|
private int _aliveNotifierIntervalMs;
|
|
|
|
|
private void ReloadAliveNotifier()
|
|
|
|
|
{
|
|
|
|
|
if (!_config.GetDlnaConfiguration().BlastAliveMessages)
|
|
|
|
|
var config = _config.GetDlnaConfiguration();
|
|
|
|
|
|
|
|
|
|
if (!config.BlastAliveMessages)
|
|
|
|
|
{
|
|
|
|
|
DisposeNotificationTimer();
|
|
|
|
|
return;
|
|
|
|
|
}
|
|
|
|
|
|
|
|
|
|
var intervalMs = _config.GetDlnaConfiguration().BlastAliveMessageIntervalSeconds * 1000;
|
|
|
|
|
var intervalMs = config.BlastAliveMessageIntervalSeconds * 1000;
|
|
|
|
|
|
|
|
|
|
if (_notificationTimer == null || _aliveNotifierIntervalMs != intervalMs)
|
|
|
|
|
{
|
|
|
|
|