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.05k stars 539 forks source link

How to send a byte array via wangle? #71

Open zhenyu-zhou opened 7 years ago

zhenyu-zhou commented 7 years ago

I have a byte array (actually the raw packet data) and I know its length. However, it may contain '\0' in the middle so that the example code doesn't work for me - such '\0' will be regarded as the end of string and I cannot send the whole array together to the destination.

I'm not quite familiar with Wangle and any idea for how to build a pipeline for my purpose?

Thanks!

P.S. The pipeline in the sample code is showed below, it works perfect for the printable strings:

auto pipeline = EchoPipeline::create();
pipeline->addBack(AsyncSocketHandler(sock));
pipeline->addBack(
    EventBaseHandler()); // ensure we can write from any thread
pipeline->addBack(LineBasedFrameDecoder(8192, false));
pipeline->addBack(StringCodec());
pipeline->addBack(EchoHandler());
djwatson commented 7 years ago

You probably want a LengthFieldBasedFrameDecoder?