protected override Boolean DoDecode(IoSession session, IoBuffer input, IProtocolDecoderOutput output)
        {
            if (!input.PrefixedDataAvailable(4, _maxObjectSize))
                return false;

            input.GetInt32();
            output.Write(input.GetObject());
            return true;
        }
Exemplo n.º 2
0
        public MessageDecoderResult Decodable(IoSession session, IoBuffer input)
        {
            if (input.Remaining < MIN_REQUIRED_FRAME_LENGTH)
                return MessageDecoderResult.NeedData;
            try
            {
                Magic.ReadAndCheckMagic(input);
            }
            catch (Exception) { return MessageDecoderResult.NotOK; }

            var frameLength = input.GetInt32();
            if (input.Remaining < frameLength)
                return MessageDecoderResult.NeedData;

            return MessageDecoderResult.OK;
        }