コード例 #1
0
        public async Task <int> ReadNextMessagesAsync(Stream outputMessageStream)
        {
            MessageCount             = 0;
            RemainingMessageDataSize = 0;

            var previousStreamPosition = outputMessageStream.Position;

            outputMessageStream.Position = outputMessageStream.Length;

            try
            {
                while (true)
                {
                    await DataStreamBuffer.ReadFromAsync(InputStream).ConfigureAwait(false);  //Populate the buffer

                    if (!ProcessStream(outputMessageStream))
                    {
                        break;
                    }
                }

                CheckEndOfStreamValidity();
            }
            finally
            {
                outputMessageStream.Position = previousStreamPosition;
                DataStreamBuffer.Reset();
            }

            return(MessageCount);
        }
コード例 #2
0
        public int ReadNextMessages(Stream outputMessageStream)
        {
            MessageCount             = 0;
            RemainingMessageDataSize = 0;

            var previousStreamPosition = outputMessageStream.Position;

            outputMessageStream.Position = outputMessageStream.Length;

            try
            {
                while (true)
                {
                    DataStreamBuffer.ReadFrom(InputStream);  //Populate the buffer
                    if (!ProcessStream(outputMessageStream))
                    {
                        break;
                    }
                }

                CheckEndOfStreamValidity();
            }
            finally
            {
                outputMessageStream.Position = previousStreamPosition;
                DataStreamBuffer.Reset();
            }

            return(MessageCount);
        }