Esempio n. 1
0
	public void PutAttribute(ControlAttribute attribute)
	{
		if (ControlHeader.CONTROL_HEADER_BYTES + header.payload_length + attribute.GetTotalLength() > CONTROL_MAX_PAYLOAD_LENGTH)
			throw new ArgumentException ("Putting attribute would exceed maximum message length");

		attributes.Add (attribute);
		header.payload_length += attribute.GetTotalLength ();
	}
Esempio n. 2
0
	public void FromBinary(BinaryReader reader)
	{
		attributes.Clear ();
		header.FromBinary (reader);

		if (header.payload_length == 0)
			return;

		int remaining = header.payload_length;

		while (remaining > 0)
		{
			if (remaining < ControlAttribute.CONTROL_ATTRIBUTE_HEADER_BYTES)
				throw new ArgumentException ("Incorrect payload - not enough data for attribute header");

			ControlAttribute attribute = ControlAttribute.FromBinary (reader);
			remaining -= attribute.GetTotalLength ();
			attributes.Add (attribute);
		}			
		Validate();
	}