using System.IO;

namespace Crysome.Common.Network.Packets.Server;

public class StartRemoteDesktopPacket : IPacket
{
	public int IntervalMs { get; set; } = 200;

	public int ScreenIndex { get; set; } = -1;

	public int UdpPort { get; set; }

	public uint SessionToken { get; set; }

	public byte CaptureMode { get; set; }

	public void Write(BinaryWriter w)
	{
		w.Write(IntervalMs);
		w.Write(ScreenIndex);
		w.Write(UdpPort);
		w.Write(SessionToken);
		w.Write(CaptureMode);
	}

	public void Read(BinaryReader r)
	{
		IntervalMs = r.ReadInt32();
		if (r.BaseStream.Position < r.BaseStream.Length)
		{
			ScreenIndex = r.ReadInt32();
		}
		if (r.BaseStream.Position < r.BaseStream.Length)
		{
			UdpPort = r.ReadInt32();
		}
		if (r.BaseStream.Position < r.BaseStream.Length)
		{
			SessionToken = r.ReadUInt32();
		}
		if (r.BaseStream.Position < r.BaseStream.Length)
		{
			CaptureMode = r.ReadByte();
		}
	}
}
