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

Update NetPeer.MessagePools.cs

Added a null check. Had been experiencing exception throws by the internal network thread due to null-reference in this method.
This commit is contained in:
AgentFire
2015-10-24 13:35:17 +03:00
parent 7e69fb2a63
commit dbf6331577

View File

@@ -106,12 +106,23 @@ namespace Lidgren.Network
/// <summary>
/// Creates a new message for sending and writes the provided string to it
/// </summary>
public NetOutgoingMessage CreateMessage(string content)
{
var om = CreateMessage(2 + content.Length); // fair guess
om.Write(content);
return om;
}
public NetOutgoingMessage CreateMessage(string content)
{
NetOutgoingMessage om;
// Since this could be null.
if (string.IsNullOrEmpty(content))
{
om = CreateMessage(1); // One byte for the internal variable-length zero byte.
}
else
{
om = CreateMessage(2 + content.Length); // Fair guess.
}
om.Write(content);
return om;
}
/// <summary>
/// Creates a new message for sending