Add NetworkMessage Guid write and read methods

This commit is contained in:
Damian Korczowski
2021-07-07 18:11:20 +02:00
parent 7e9f648a05
commit e62c76b0fb
2 changed files with 36 additions and 0 deletions

View File

@@ -275,6 +275,24 @@ namespace FlaxEngine.Networking
return new string(bytes, 0, stringLength);
}
/// <summary>
/// Writes data of type <see cref="Guid"/> into the message.
/// </summary>
public void WriteGuid(Guid value)
{
WriteBytes((byte*)&value, sizeof(Guid));
}
/// <summary>
/// Reads and returns data of type <see cref="Guid"/> from the message.
/// </summary>
public Guid ReadGuid()
{
var guidData = stackalloc Guid[1];
ReadBytes((byte*)guidData, sizeof(Guid));
return guidData[0];
}
/// <summary>
/// Writes data of type <see cref="Vector2"/> into the message.
/// </summary>

View File

@@ -201,6 +201,24 @@ public:
ReadBytes((uint8*)value.Get(), length * sizeof(wchar_t));
return value;
}
/// <summary>
/// Writes data of type Guid into the message.
/// </summary>
FORCE_INLINE void WriteGuid(const Guid& value)
{
WriteBytes((uint8*)&value, sizeof(Guid));
}
/// <summary>
/// Reads and returns data of type Guid from the message.
/// </summary>
FORCE_INLINE Guid ReadGuid()
{
Guid value = Guid();
ReadBytes((uint8*)&value, sizeof(Guid));
return value;
}
public:
/// <summary>