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

Merge pull request #49 from AgentFire/patch-2

Update NetPeer.MessagePools.cs
This commit is contained in:
lidgren
2015-10-26 09:24:06 +01:00

View File

@@ -106,12 +106,23 @@ namespace Lidgren.Network
/// <summary> /// <summary>
/// Creates a new message for sending and writes the provided string to it /// Creates a new message for sending and writes the provided string to it
/// </summary> /// </summary>
public NetOutgoingMessage CreateMessage(string content) public NetOutgoingMessage CreateMessage(string content)
{ {
var om = CreateMessage(2 + content.Length); // fair guess NetOutgoingMessage om;
om.Write(content);
return 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> /// <summary>
/// Creates a new message for sending /// Creates a new message for sending