diff --git a/MediaBrowser.Dlna/Ssdp/SsdpHandler.cs b/MediaBrowser.Dlna/Ssdp/SsdpHandler.cs index 6159b18f0..28ea5ad6c 100644 --- a/MediaBrowser.Dlna/Ssdp/SsdpHandler.cs +++ b/MediaBrowser.Dlna/Ssdp/SsdpHandler.cs @@ -333,6 +333,11 @@ namespace MediaBrowser.Dlna.Ssdp var args = SsdpHelper.ParseSsdpResponse(received); args.EndPoint = endpoint; + if (IsSelfNotification(args)) + { + return; + } + if (enableDebugLogging) { 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() { _config.NamedConfigurationUpdated -= _config_ConfigurationUpdated;