ByteToMessageDecoder decode
zhwaaaaaa opened this issue · 0 comments
zhwaaaaaa commented
If a custom frame decoder is required, then one needs to be careful
- when implementing one with {@link ByteToMessageDecoder}. Ensure
- there are enough bytes in the buffer for a complete frame by
- checking {@link ByteBuf#readableBytes()}. If there are not enough
- bytes for a complete frame, return without modify the reader index
- to allow more bytes to arrive.
I found the same explanatory note in netty, but I cannot find any classes called Bytebuf.
virtual bool decode(Context* ctx, folly::IOBufQueue& buf, M& result, size_t&) = 0; void read(Context* ctx, folly::IOBufQueue& q) override { bool success = true; while (success && transportActive_) { M result; size_t needed = 0; success = decode(ctx, q, result, needed); if (success) { ctx->fireRead(std::move(result)); } } }
the last parameter seems unnecessary in decode function