You've already forked lidgren-network-gen3
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:
@@ -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
|
||||
|
||||
Reference in New Issue
Block a user