zz
This commit is contained in:
36
GlobalTorch/Util/SendBuffer.cs
Normal file
36
GlobalTorch/Util/SendBuffer.cs
Normal file
@@ -0,0 +1,36 @@
|
||||
using System;
|
||||
using VRage.Library.Collections;
|
||||
|
||||
namespace Global.Util
|
||||
{
|
||||
internal class SendBuffer : IBitSerializable
|
||||
{
|
||||
public int NumElements;
|
||||
public long SenderUserId;
|
||||
public byte[] VoiceDataBuffer;
|
||||
|
||||
public bool Serialize(BitStream stream, bool validate, bool acceptAndSetValue = true)
|
||||
{
|
||||
if (stream.Reading)
|
||||
{
|
||||
SenderUserId = stream.ReadInt64();
|
||||
NumElements = stream.ReadInt32();
|
||||
ArrayExtensions.EnsureCapacity(ref VoiceDataBuffer, NumElements);
|
||||
stream.ReadBytes(VoiceDataBuffer, 0, NumElements);
|
||||
}
|
||||
else
|
||||
{
|
||||
stream.WriteInt64(SenderUserId);
|
||||
stream.WriteInt32(NumElements);
|
||||
stream.WriteBytes(VoiceDataBuffer, 0, NumElements);
|
||||
}
|
||||
|
||||
return true;
|
||||
}
|
||||
|
||||
public static implicit operator BitReaderWriter(SendBuffer buffer)
|
||||
{
|
||||
return new BitReaderWriter(buffer);
|
||||
}
|
||||
}
|
||||
}
|
Reference in New Issue
Block a user