ReadRawByte() публичный Метод

Read one byte from the input.
/// the end of the stream or the current limit was reached ///
public ReadRawByte ( ) : byte
Результат byte
Пример #1
0
        public void ResetSizeCounter()
        {
            CodedInputStream input = CodedInputStream.CreateInstance(
                new SmallBlockInputStream(new byte[256], 8));

            input.SetSizeLimit(16);
            input.ReadRawBytes(16);

            try
            {
                input.ReadRawByte();
                Assert.Fail("Should have thrown an exception!");
            }
            catch (InvalidProtocolBufferException)
            {
                // Success.
            }

            input.ResetSizeCounter();
            input.ReadRawByte(); // No exception thrown.

            try
            {
                input.ReadRawBytes(16); // Hits limit again.
                Assert.Fail("Should have thrown an exception!");
            }
            catch (InvalidProtocolBufferException)
            {
                // Success.
            }
        }
Пример #2
0
        public Header(CodedInputStream stream)
        {
            var serviceId = stream.ReadRawByte();
            var methodId = stream.ReadRawVarint32();
            var requestId = stream.ReadRawByte() | (stream.ReadRawByte() << 8);
            if (serviceId != 0xfe) this.Unknown = stream.ReadRawVarint64();
            var payloadLength = stream.ReadRawVarint32();

            this.SetData(serviceId, methodId, requestId, payloadLength);
        }
Пример #3
0
        public PacketIn(CodedInputStream stream)
        {
            this._stream = stream;

            this.ServiceId = stream.ReadRawByte();
            this.MethodId = stream.ReadRawVarint32();
            this.RequestId = stream.ReadRawByte() | (stream.ReadRawByte() << 8);

            this.ObjectId = 0UL;
            if (this.ServiceId != 0xfe) this.ObjectId = stream.ReadRawVarint64();
        }
Пример #4
0
        public BNetHeader(CodedInputStream stream)
        {
            var serviceId = stream.ReadRawByte();
            var methodId = stream.ReadRawVarint32();
            var requestId = stream.ReadRawByte() | (stream.ReadRawByte() << 8);

            var objectId = 0UL;
            if (serviceId != 0xfe) objectId = stream.ReadRawVarint64();
            var payloadLength = stream.ReadRawVarint32();

            this.SetData(serviceId, methodId, requestId, payloadLength, objectId);
        }
Пример #5
0
        public void ResetSizeCounter()
        {
            CodedInputStream input = CodedInputStream.CreateInstance(
                new SmallBlockInputStream(new byte[256], 8));

            input.SetSizeLimit(16);
            input.ReadRawBytes(16);

            Assert.Throws <InvalidProtocolBufferException>(() => input.ReadRawByte());

            input.ResetSizeCounter();
            input.ReadRawByte(); // No exception thrown.

            Assert.Throws <InvalidProtocolBufferException>(() => input.ReadRawBytes(16));
        }
Пример #6
0
        public void SkipRawBytesBug()
        {
            byte[]           rawBytes = new byte[] { 1, 2 };
            CodedInputStream input    = CodedInputStream.CreateInstance(rawBytes);

            int limit = input.PushLimit(1);

            input.SkipRawBytes(1);
            input.PopLimit(limit);
            Assert.AreEqual(2, input.ReadRawByte());
        }
Пример #7
0
        public ClientPacket(CodedInputStream stream)
        {
            m_stream = stream;

            // Read header
            m_service = m_stream.ReadRawByte();
            m_method = m_stream.ReadInt32();
            m_requestId = m_stream.ReadInt16();
            m_listenerId = 0;

            Console.WriteLine("IN: service {0}, method {1:X}, requestId {2}, listenerId {3}", m_service, m_method, m_requestId, m_listenerId);

            if (m_service != 0xFE)
                m_listenerId = m_stream.ReadRawVarint64();
        }