Example #1
0
        internal static Frame ReadFromStream(Stream stream)
        {
            Frame frame = new Frame();


            byte[] buffer = new byte[BufferSize];

            BinaryReader br         = new BinaryReader(stream);
            var          size       = br.ReadInt32();
            var          dataOffset = br.ReadByte();
            var          type       = br.ReadByte();

            var frameType = (FrameType)((int)type);

            if (frameType == FrameType.AMQP)
            {
                return(AMQPFrame.ReadFromStream(br, size, dataOffset, frameType));
            }
            else if (frameType == FrameType.SASL)
            {
            }
            else
            {
                throw new Exception("Unknown FrameType " + frameType.ToString());
            }

            stream.Read(buffer, 0, 8);



            return(frame);
        }
Example #2
0
        internal static Frame ReadFromStream(BinaryReader br, int size, byte dataOffset, FrameType frameType)
        {
            var channelNumber = br.ReadUInt16();

            var ignoredExtendedHeader = br.ReadBytes((dataOffset * 4) - 8);

            var performative = (PerformativeType)(int)br.ReadByte();

            AMQPFrame frame = null;

            switch (performative)
            {
            case PerformativeType.Open:
                frame = new OpenFrame(br, dataOffset, size, channelNumber);
                break;
            }

            return(frame);
        }