/// <summary> /// Parses the first 8 or 9 bytes and returns a FrameHeader /// </summary> public static FrameHeader ParseResponseHeader(ProtocolVersion version, byte[] buffer, int offset) { var header = new FrameHeader() { _versionByte = buffer[offset++], Flags = (HeaderFlag)buffer[offset++] }; if (!version.Uses2BytesStreamIds()) { //Stream id is a signed byte in v1 and v2 of the protocol header.StreamId = (sbyte)buffer[offset++]; } else { header.StreamId = BeConverter.ToInt16(buffer, offset); offset += 2; } header.Opcode = buffer[offset++]; header.BodyLength = BeConverter.ToInt32(Utils.SliceBuffer(buffer, offset, 4)); return(header); }
/// <summary> /// Parses a ushort from the following 2 bytes /// </summary> public short ReadInt16() { _stream.Read(_buffer, 0, 2); return(BeConverter.ToInt16(_buffer)); }