avoid responding to self messages

pull/702/head
Luke Pulverenti 10 years ago
parent 4bf8c8211f
commit fabb4f4c95

@ -333,6 +333,11 @@ namespace MediaBrowser.Dlna.Ssdp
var args = SsdpHelper.ParseSsdpResponse(received); var args = SsdpHelper.ParseSsdpResponse(received);
args.EndPoint = endpoint; args.EndPoint = endpoint;
if (IsSelfNotification(args))
{
return;
}
if (enableDebugLogging) if (enableDebugLogging)
{ {
var headerTexts = args.Headers.Select(i => string.Format("{0}={1}", i.Key, i.Value)); var headerTexts = args.Headers.Select(i => string.Format("{0}={1}", i.Key, i.Value));
@ -354,6 +359,44 @@ namespace MediaBrowser.Dlna.Ssdp
} }
} }
internal bool IsSelfNotification(SsdpMessageEventArgs args)
{
// Avoid responding to self search messages
//string serverId;
//if (args.Headers.TryGetValue("X-EMBYSERVERID", out serverId) &&
// string.Equals(serverId, _appHost.SystemId, StringComparison.OrdinalIgnoreCase))
//{
// return true;
//}
string server;
args.Headers.TryGetValue("SERVER", out server);
if (string.Equals(server, _serverSignature, StringComparison.OrdinalIgnoreCase))
{
return true;
}
return false;
//string usn;
//args.Headers.TryGetValue("USN", out usn);
//if (string.IsNullOrWhiteSpace(usn))
//{
// return false;
//}
//_logger.Debug("IsSelfNotification test: " + usn);
//return RegisteredDevices.Any(i =>
//{
// var isSameDevice = string.Equals(usn, i.USN, StringComparison.OrdinalIgnoreCase) ||
// i.USN.IndexOf(usn, StringComparison.OrdinalIgnoreCase) != 1 ||
// usn.IndexOf(i.USN, StringComparison.OrdinalIgnoreCase) != 1;
// return isSameDevice;
//});
}
public void Dispose() public void Dispose()
{ {
_config.NamedConfigurationUpdated -= _config_ConfigurationUpdated; _config.NamedConfigurationUpdated -= _config_ConfigurationUpdated;

Loading…
Cancel
Save