using System.IO;

namespace Crysome.Common.Network.Packets.Client;

public class CameraFramePacket : IPacket
{
	public byte[] JpegData { get; set; }

	public CameraFramePacket()
	{
	}

	public CameraFramePacket(byte[] jpegData)
	{
		JpegData = jpegData;
	}

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

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