You've already forked lidgren-network-gen3
mirror of
https://github.com/lidgren/lidgren-network-gen3.git
synced 2026-05-15 22:56:30 +09:00
Release build fixed for NetPeerSettingsWindow
ManyClients project excluded missing app.config file Reduced number of calls to NetTime.Now when receiving multiple messages Moved magic numbers to constants in NetConnection
This commit is contained in:
@@ -11,6 +11,9 @@ namespace Lidgren.Network
|
||||
[DebuggerDisplay("RemoteUniqueIdentifier={RemoteUniqueIdentifier} RemoteEndPoint={remoteEndPoint}")]
|
||||
public partial class NetConnection
|
||||
{
|
||||
private const int m_infrequentEventsSkipFrames = 8; // number of heartbeats to skip checking for infrequent events (ping, timeout etc)
|
||||
private const int m_messageCoalesceFrames = 3; // number of heartbeats to wait for more incoming messages before sending packet
|
||||
|
||||
internal NetPeer m_peer;
|
||||
internal NetPeerConfiguration m_peerConfiguration;
|
||||
internal NetConnectionStatus m_status;
|
||||
@@ -138,7 +141,7 @@ namespace Lidgren.Network
|
||||
|
||||
NetException.Assert(m_status != NetConnectionStatus.InitiatedConnect && m_status != NetConnectionStatus.RespondedConnect);
|
||||
|
||||
if ((frameCounter % 5) == 0)
|
||||
if ((frameCounter % m_infrequentEventsSkipFrames) == 0)
|
||||
{
|
||||
if (now > m_timeoutDeadline)
|
||||
{
|
||||
@@ -175,7 +178,7 @@ namespace Lidgren.Network
|
||||
byte[] sendBuffer = m_peer.m_sendBuffer;
|
||||
int mtu = m_currentMTU;
|
||||
|
||||
if ((frameCounter % 3) == 0) // coalesce a few frames
|
||||
if ((frameCounter % m_messageCoalesceFrames) == 0) // coalesce a few frames
|
||||
{
|
||||
//
|
||||
// send ack messages
|
||||
|
||||
@@ -36,7 +36,7 @@ namespace Lidgren.Network
|
||||
internal long m_uniqueIdentifier;
|
||||
internal bool m_executeFlushSendQueue;
|
||||
|
||||
private AutoResetEvent m_messageReceivedEvent = new AutoResetEvent(false);
|
||||
private AutoResetEvent m_messageReceivedEvent;
|
||||
private List<NetTuple<SynchronizationContext, SendOrPostCallback>> m_receiveCallbacks;
|
||||
|
||||
/// <summary>
|
||||
@@ -369,6 +369,10 @@ namespace Lidgren.Network
|
||||
//if (m_socket == null || m_socket.Available < 1)
|
||||
// return;
|
||||
|
||||
// update now
|
||||
dnow = NetTime.Now;
|
||||
now = (float)dnow;
|
||||
|
||||
do
|
||||
{
|
||||
int bytesReceived = 0;
|
||||
@@ -418,7 +422,6 @@ namespace Lidgren.Network
|
||||
NetConnection sender = null;
|
||||
m_connectionLookup.TryGetValue(ipsender, out sender);
|
||||
|
||||
double receiveTime = NetTime.Now;
|
||||
//
|
||||
// parse packet into messages
|
||||
//
|
||||
@@ -460,7 +463,7 @@ namespace Lidgren.Network
|
||||
if (sender != null)
|
||||
sender.ReceivedLibraryMessage(tp, ptr, payloadByteLength);
|
||||
else
|
||||
ReceivedUnconnectedLibraryMessage(receiveTime, ipsender, tp, ptr, payloadByteLength);
|
||||
ReceivedUnconnectedLibraryMessage(dnow, ipsender, tp, ptr, payloadByteLength);
|
||||
}
|
||||
else
|
||||
{
|
||||
@@ -469,7 +472,7 @@ namespace Lidgren.Network
|
||||
|
||||
NetIncomingMessage msg = CreateIncomingMessage(NetIncomingMessageType.Data, payloadByteLength);
|
||||
msg.m_isFragment = isFragment;
|
||||
msg.m_receiveTime = receiveTime;
|
||||
msg.m_receiveTime = dnow;
|
||||
msg.m_sequenceNumber = sequenceNumber;
|
||||
msg.m_receivedMessageType = tp;
|
||||
msg.m_senderConnection = sender;
|
||||
|
||||
@@ -31,7 +31,15 @@ namespace Lidgren.Network
|
||||
/// find the message in the queue. Other user created threads could be preempted and dequeue
|
||||
/// the message before the waiting thread wakes up.
|
||||
/// </summary>
|
||||
public AutoResetEvent MessageReceivedEvent { get { return m_messageReceivedEvent; } }
|
||||
public AutoResetEvent MessageReceivedEvent
|
||||
{
|
||||
get
|
||||
{
|
||||
if (m_messageReceivedEvent == null)
|
||||
m_messageReceivedEvent = new AutoResetEvent(false);
|
||||
return m_messageReceivedEvent;
|
||||
}
|
||||
}
|
||||
|
||||
/// <summary>
|
||||
/// Gets a unique identifier for this NetPeer based on Mac address and ip/port. Note! Not available until Start() has been called!
|
||||
|
||||
Reference in New Issue
Block a user