Fix null String serialization over network via C# API
This commit is contained in:
@@ -237,10 +237,14 @@ namespace FlaxEngine.Networking
|
||||
{
|
||||
// Note: Make sure that this is consistent with the C++ message API!
|
||||
|
||||
if (value == null)
|
||||
{
|
||||
WriteUInt16(0);
|
||||
return;
|
||||
}
|
||||
var data = Encoding.Unicode.GetBytes(value);
|
||||
var dataLength = data.Length;
|
||||
var stringLength = value.Length;
|
||||
|
||||
WriteUInt16((ushort)stringLength); // TODO: Use 1-byte length when possible
|
||||
WriteBytes(data, dataLength);
|
||||
}
|
||||
@@ -253,6 +257,8 @@ namespace FlaxEngine.Networking
|
||||
// Note: Make sure that this is consistent with the C++ message API!
|
||||
|
||||
var stringLength = ReadUInt16(); // In chars
|
||||
if (stringLength == 0)
|
||||
return string.Empty;
|
||||
var dataLength = stringLength * sizeof(char); // In bytes
|
||||
var bytes = stackalloc char[stringLength];
|
||||
|
||||
|
||||
Reference in New Issue
Block a user