Add Write/Read methods to NetworkStream for INetworkSerializable sending in C# api

This commit is contained in:
Wojtek Figat
2024-04-22 23:25:19 +02:00
parent 4fbe210730
commit 203f03a597

View File

@@ -1,4 +1,4 @@
// Copyright (c) 2012-2024 Wojciech Figat. All rights reserved.
// Copyright (c) 2012-2024 Wojciech Figat. All rights reserved.
using System;
using System.Text;
@@ -441,5 +441,23 @@ namespace FlaxEngine.Networking
ReadBytes((byte*)&value, sizeof(bool));
return value;
}
/// <summary>
/// Writes the <see cref="INetworkSerializable"/> object data to the stream. Object has to be allocated.
/// </summary>
/// <param name="obj">The serializable object.</param>
public void Write(INetworkSerializable obj)
{
obj.Serialize(this);
}
/// <summary>
/// Reads the <see cref="INetworkSerializable"/> object data from the stream. Object has to be allocated.
/// </summary>
/// <param name="obj">The serializable object.</param>
public void Read(INetworkSerializable obj)
{
obj.Deserialize(this);
}
}
}