aboutsummaryrefslogtreecommitdiff
diff options
context:
space:
mode:
authorLuke Pulverenti <luke.pulverenti@gmail.com>2016-02-17 16:40:17 -0500
committerLuke Pulverenti <luke.pulverenti@gmail.com>2016-02-17 16:40:17 -0500
commitbfa1b30cab05577844a9d34e4519c89ebc84aa91 (patch)
tree1f2d5625a30b009a6cbee0178de7394611d1569e
parentf13ca8f343c3e7b782facbaa4e42b7f8a26246b5 (diff)
update RespondToSearch
-rw-r--r--MediaBrowser.Dlna/Ssdp/SsdpHandler.cs39
1 files changed, 30 insertions, 9 deletions
diff --git a/MediaBrowser.Dlna/Ssdp/SsdpHandler.cs b/MediaBrowser.Dlna/Ssdp/SsdpHandler.cs
index 6e85918f4..278c34275 100644
--- a/MediaBrowser.Dlna/Ssdp/SsdpHandler.cs
+++ b/MediaBrowser.Dlna/Ssdp/SsdpHandler.cs
@@ -144,7 +144,7 @@ namespace MediaBrowser.Dlna.Ssdp
//var protocol = isMulticast ? "Multicast" : "Unicast";
//var localEndPointString = args.LocalEndPoint == null ? "null" : args.LocalEndPoint.ToString();
//_logger.Debug("IGNORING {0} message received from {1} on {3}. Protocol: {4} Headers: {2}", args.Method, args.EndPoint, headerText, localEndPointString, protocol);
-
+
return true;
}
}
@@ -164,7 +164,7 @@ namespace MediaBrowser.Dlna.Ssdp
return true;
}
}
-
+
return false;
}
@@ -303,9 +303,17 @@ namespace MediaBrowser.Dlna.Ssdp
var msg = new SsdpMessageBuilder().BuildMessage(header, values);
- SendDatagram(msg, endpoint, null, false, 2);
- SendDatagram(msg, endpoint, new IPEndPoint(d.Address, 0), false, 2);
- //SendDatagram(header, values, endpoint, null, true);
+ var ipEndPoint = endpoint as IPEndPoint;
+ if (ipEndPoint != null)
+ {
+ SendUnicastRequest(msg, ipEndPoint);
+ }
+ else
+ {
+ SendDatagram(msg, endpoint, null, false, 2);
+ SendDatagram(msg, endpoint, new IPEndPoint(d.Address, 0), false, 2);
+ //SendDatagram(header, values, endpoint, null, true);
+ }
if (enableDebugLogging)
{
@@ -583,12 +591,12 @@ namespace MediaBrowser.Dlna.Ssdp
}
catch (ObjectDisposedException)
{
-
+
}
}
}
- private async void SendUnicastRequest(string request, int sendCount = 3)
+ private void SendUnicastRequest(string request, int sendCount = 3)
{
if (_unicastClient == null)
{
@@ -597,10 +605,23 @@ namespace MediaBrowser.Dlna.Ssdp
_logger.Debug("Sending unicast search request");
- byte[] req = Encoding.ASCII.GetBytes(request);
var ipSsdp = IPAddress.Parse(SSDPAddr);
var ipTxEnd = new IPEndPoint(ipSsdp, SSDPPort);
+ SendUnicastRequest(request, ipTxEnd, sendCount);
+ }
+
+ private async void SendUnicastRequest(string request, IPEndPoint toEndPoint, int sendCount = 3)
+ {
+ if (_unicastClient == null)
+ {
+ return;
+ }
+
+ _logger.Debug("Sending unicast search request");
+
+ byte[] req = Encoding.ASCII.GetBytes(request);
+
try
{
for (var i = 0; i < sendCount; i++)
@@ -609,7 +630,7 @@ namespace MediaBrowser.Dlna.Ssdp
{
await Task.Delay(50).ConfigureAwait(false);
}
- _unicastClient.Send(req, req.Length, ipTxEnd);
+ _unicastClient.Send(req, req.Length, toEndPoint);
}
}
catch (Exception ex)