You've already forked lidgren-network-gen3
mirror of
https://github.com/lidgren/lidgren-network-gen3.git
synced 2026-05-17 15:46:33 +09:00
@@ -180,15 +180,24 @@ namespace Lidgren.Network
|
|||||||
/// <summary>
|
/// <summary>
|
||||||
/// Read a pending message from any connection, blocking up to maxMillis if needed
|
/// Read a pending message from any connection, blocking up to maxMillis if needed
|
||||||
/// </summary>
|
/// </summary>
|
||||||
public NetIncomingMessage WaitMessage(int maxMillis)
|
public NetIncomingMessage WaitMessage(int maxMillis)
|
||||||
{
|
{
|
||||||
var msg = ReadMessage();
|
NetIncomingMessage msg = ReadMessage();
|
||||||
if (msg != null)
|
|
||||||
return msg; // no need to wait; we already have a message to deliver
|
while (msg == null)
|
||||||
var msgEvt = MessageReceivedEvent;
|
{
|
||||||
msgEvt.WaitOne(maxMillis);
|
// This could return true...
|
||||||
return ReadMessage();
|
if (!MessageReceivedEvent.WaitOne(maxMillis))
|
||||||
}
|
{
|
||||||
|
return null;
|
||||||
|
}
|
||||||
|
|
||||||
|
// ... while this will still returns null. That's why we need to cycle.
|
||||||
|
msg = ReadMessage();
|
||||||
|
}
|
||||||
|
|
||||||
|
return msg;
|
||||||
|
}
|
||||||
|
|
||||||
/// <summary>
|
/// <summary>
|
||||||
/// Read a pending message from any connection, if any
|
/// Read a pending message from any connection, if any
|
||||||
|
|||||||
Reference in New Issue
Block a user