using System.IO;

namespace Crysome.Common.Network.Packets.Client;

public class AudioDataPacket : IPacket
{
	public byte[] WavData { get; set; }

	public AudioDataPacket()
	{
	}

	public AudioDataPacket(byte[] wavData)
	{
		WavData = wavData;
	}

	public void Write(BinaryWriter w)
	{
		w.Write((WavData != null) ? WavData.Length : 0);
		if (WavData != null && WavData.Length != 0)
		{
			w.Write(WavData);
		}
	}

	public void Read(BinaryReader r)
	{
		int num = r.ReadInt32();
		WavData = ((num > 0) ? r.ReadBytes(num) : new byte[0]);
	}
}
