You've already forked lidgren-network-gen3
mirror of
https://github.com/lidgren/lidgren-network-gen3.git
synced 2026-05-17 23:56:30 +09:00
Merge pull request #28 from MichaelDePiazzi/upnp-timeout
UPnP discovery timeout
This commit is contained in:
@@ -389,6 +389,9 @@ namespace Lidgren.Network
|
|||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
|
if (m_upnp != null)
|
||||||
|
m_upnp.CheckForDiscoveryTimeout();
|
||||||
|
|
||||||
//
|
//
|
||||||
// read from socket
|
// read from socket
|
||||||
//
|
//
|
||||||
|
|||||||
@@ -71,6 +71,7 @@ namespace Lidgren.Network
|
|||||||
"MAN:\"ssdp:discover\"\r\n" +
|
"MAN:\"ssdp:discover\"\r\n" +
|
||||||
"MX:3\r\n\r\n";
|
"MX:3\r\n\r\n";
|
||||||
|
|
||||||
|
m_discoveryResponseDeadline = NetTime.Now + 6.0; // arbitrarily chosen number, router gets 6 seconds to respond
|
||||||
m_status = UPnPStatus.Discovering;
|
m_status = UPnPStatus.Discovering;
|
||||||
|
|
||||||
byte[] arr = System.Text.Encoding.UTF8.GetBytes(str);
|
byte[] arr = System.Text.Encoding.UTF8.GetBytes(str);
|
||||||
@@ -79,14 +80,16 @@ namespace Lidgren.Network
|
|||||||
peer.Socket.SetSocketOption(SocketOptionLevel.Socket, SocketOptionName.Broadcast, true);
|
peer.Socket.SetSocketOption(SocketOptionLevel.Socket, SocketOptionName.Broadcast, true);
|
||||||
peer.RawSend(arr, 0, arr.Length, new NetEndPoint(NetUtility.GetBroadcastAddress(), 1900));
|
peer.RawSend(arr, 0, arr.Length, new NetEndPoint(NetUtility.GetBroadcastAddress(), 1900));
|
||||||
peer.Socket.SetSocketOption(SocketOptionLevel.Socket, SocketOptionName.Broadcast, false);
|
peer.Socket.SetSocketOption(SocketOptionLevel.Socket, SocketOptionName.Broadcast, false);
|
||||||
|
|
||||||
// allow some extra time for router to respond
|
|
||||||
NetUtility.Sleep(50);
|
|
||||||
|
|
||||||
m_discoveryResponseDeadline = NetTime.Now + 6.0; // arbitrarily chosen number, router gets 6 seconds to respond
|
|
||||||
m_status = UPnPStatus.Discovering;
|
|
||||||
}
|
}
|
||||||
|
|
||||||
|
internal void CheckForDiscoveryTimeout()
|
||||||
|
{
|
||||||
|
if ((m_status != UPnPStatus.Discovering) || (NetTime.Now < m_discoveryResponseDeadline))
|
||||||
|
return;
|
||||||
|
m_peer.LogDebug("UPnP discovery timed out");
|
||||||
|
m_status = UPnPStatus.NotAvailable;
|
||||||
|
}
|
||||||
|
|
||||||
internal void ExtractServiceUrl(string resp)
|
internal void ExtractServiceUrl(string resp)
|
||||||
{
|
{
|
||||||
#if !DEBUG
|
#if !DEBUG
|
||||||
|
|||||||
Reference in New Issue
Block a user