1
0
mirror of https://github.com/lidgren/lidgren-network-gen3.git synced 2026-05-16 07:06:30 +09:00

Merge pull request #48 from AgentFire/patch-2

Update NetPeer.cs
This commit is contained in:
lidgren
2015-10-05 16:09:14 +02:00

View File

@@ -180,15 +180,24 @@ namespace Lidgren.Network
/// <summary>
/// Read a pending message from any connection, blocking up to maxMillis if needed
/// </summary>
public NetIncomingMessage WaitMessage(int maxMillis)
{
var msg = ReadMessage();
if (msg != null)
return msg; // no need to wait; we already have a message to deliver
var msgEvt = MessageReceivedEvent;
msgEvt.WaitOne(maxMillis);
return ReadMessage();
}
public NetIncomingMessage WaitMessage(int maxMillis)
{
NetIncomingMessage msg = ReadMessage();
while (msg == null)
{
// This could return true...
if (!MessageReceivedEvent.WaitOne(maxMillis))
{
return null;
}
// ... while this will still returns null. That's why we need to cycle.
msg = ReadMessage();
}
return msg;
}
/// <summary>
/// Read a pending message from any connection, if any