facebook / wangle

Wangle is a framework providing a set of common client/server abstractions for building services in a consistent, modular, and composable way.
Apache License 2.0
3.04k stars 535 forks source link

ByteToMessageDecoder decode #176

Open zhwaaaaaa opened 4 years ago

zhwaaaaaa commented 4 years ago

If a custom frame decoder is required, then one needs to be careful

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