public override XFPacket Parse(byte[] messageAsBytes) { List<Byte> message = messageAsBytes.ToList(); parseMessageLength(message); parsePacketID(message); while (message.Count > 0) { Structure.XFPacketAttribute attribute = new Structure.XFPacketAttribute(pEncodingInstance); attribute.Name = BitConverter.ToInt16(message.GetRange(0, 2).ToArray(), 0).ToString(); message.RemoveRange(0, 2); Int32 typeOfAttribute = Convert.ToInt32(message[0]); message.RemoveAt(0); attribute.Value = Structure.XFPacketValue.GetValueTypeForID(typeOfAttribute, message, pEncodingInstance); addAttribute(attribute); attribute = new Structure.XFPacketAttribute(pEncodingInstance); attribute.Name = message.GetRange(0, 1).ToArray()[0].ToString(); message.RemoveRange(0, 1); typeOfAttribute = Convert.ToInt32(message[0]); message.RemoveAt(0); attribute.Value = Structure.XFPacketValue.GetValueTypeForID(typeOfAttribute, message, pEncodingInstance); addAttribute(attribute); } return this; }
/// <summary> /// Initializes a new instance of the <see cref="XFVersionPacket"/> class. /// </summary> /// <param name="ClientVersion">The client version.</param> public XFVersionPacket(PlgXfire.Networking.NetworkProviders.XfireNetworkProvider protocolInstance, System.Text.Encoding encodingInstance, Int32 clientVersion) : base(protocolInstance, encodingInstance) { this.pMessageID = BitConverter.ToInt16(new Byte[] { 0x03, 0x00 }, 0); pClientVersion = clientVersion; Structure.XFPacketAttribute version = new Structure.XFPacketAttribute(encodingInstance); version.Name = "version"; version.Value = new Structure.ValueTypes.XFInt32(encodingInstance, clientVersion); this.addAttribute(version); }