namespace QC.QMSLPhone;

public class AsyncMessage
{
	public ushort msgID;

	public byte[] message;

	public AsyncMessage(ushort messageID, byte[] msg)
	{
		msgID = messageID;
		message = new byte[msg.Length];
		for (int i = 0; i < msg.Length; i++)
		{
			message[i] = msg[i];
		}
	}

	public short getShort(int stIndex)
	{
		return (short)((message[stIndex + 1] << 8) + message[stIndex]);
	}

	public ushort getWord(int stIndex)
	{
		return (ushort)((message[stIndex + 1] << 8) + message[stIndex]);
	}

	public uint getUint32(int stIndex)
	{
		uint num = 0u;
		for (int num2 = stIndex + 3; num2 >= stIndex; num2--)
		{
			num <<= 8;
			num += message[num2];
		}
		return num;
	}

	public ulong getUint64(int stIndex)
	{
		ulong num = 0uL;
		for (int num2 = stIndex + 7; num2 >= stIndex; num2--)
		{
			num <<= 8;
			num += message[num2];
		}
		return num;
	}

	public override string ToString()
	{
		string text = "";
		byte[] array = message;
		foreach (byte b in array)
		{
			text += $"{b:x2} ";
		}
		return text;
	}
}
