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
NetOutgoingMessage.Write(string) now preallocates the correct amount of memory
NetPeer.MessageAvailable added
This commit is contained in:
@@ -518,7 +518,7 @@ namespace Lidgren.Network
|
|||||||
}
|
}
|
||||||
|
|
||||||
byte[] bytes = Encoding.UTF8.GetBytes(source);
|
byte[] bytes = Encoding.UTF8.GetBytes(source);
|
||||||
EnsureBufferSize(m_bitLength + 1 + bytes.Length);
|
EnsureBufferSize(m_bitLength + 1 + (bytes.Length * 8));
|
||||||
WriteVariableUInt32((uint)bytes.Length);
|
WriteVariableUInt32((uint)bytes.Length);
|
||||||
Write(bytes);
|
Write(bytes);
|
||||||
}
|
}
|
||||||
|
|||||||
@@ -150,6 +150,19 @@ namespace Lidgren.Network
|
|||||||
Thread.Sleep(3);
|
Thread.Sleep(3);
|
||||||
}
|
}
|
||||||
|
|
||||||
|
/// <summary>
|
||||||
|
/// Returns true if there is a queued message available to read using ReadMessage()
|
||||||
|
/// </summary>
|
||||||
|
public bool MessageAvailable
|
||||||
|
{
|
||||||
|
get
|
||||||
|
{
|
||||||
|
if (m_status == NetPeerStatus.NotRunning)
|
||||||
|
return false;
|
||||||
|
return (m_releasedIncomingMessages.Count > 0);
|
||||||
|
}
|
||||||
|
}
|
||||||
|
|
||||||
/// <summary>
|
/// <summary>
|
||||||
/// Read a pending message from any connection, if any
|
/// Read a pending message from any connection, if any
|
||||||
/// </summary>
|
/// </summary>
|
||||||
|
|||||||
@@ -93,9 +93,10 @@ namespace Lidgren.Network
|
|||||||
m_disabledTypes = NetIncomingMessageType.ConnectionApproval | NetIncomingMessageType.UnconnectedData | NetIncomingMessageType.VerboseDebugMessage;
|
m_disabledTypes = NetIncomingMessageType.ConnectionApproval | NetIncomingMessageType.UnconnectedData | NetIncomingMessageType.VerboseDebugMessage;
|
||||||
|
|
||||||
// Maximum transmission unit
|
// Maximum transmission unit
|
||||||
|
// Ethernet can take 1500 bytes of payload, so lets stay below that.
|
||||||
// The aim is for a max full packet to be 1440 bytes (30 x 48 bytes, lower than 1468)
|
// The aim is for a max full packet to be 1440 bytes (30 x 48 bytes, lower than 1468)
|
||||||
// 20 bytes ip header
|
// 20 bytes IP header
|
||||||
// 8 bytes udp header
|
// 8 bytes UDP header
|
||||||
// 5 bytes lidgren header for one message
|
// 5 bytes lidgren header for one message
|
||||||
// 1 byte just to be on the safe side
|
// 1 byte just to be on the safe side
|
||||||
// Totals 1440 minus 34 = 1406 bytes free for payload
|
// Totals 1440 minus 34 = 1406 bytes free for payload
|
||||||
|
|||||||
Reference in New Issue
Block a user