proxygen
|
Public Member Functions | |
bool | decode (Context *, IOBufQueue &buf, std::string &result, size_t &) override |
Public Member Functions inherited from wangle::ByteToMessageDecoder< std::string > | |
void | transportActive (Context *ctx) override |
void | transportInactive (Context *ctx) override |
void | read (Context *ctx, folly::IOBufQueue &q) override |
Public Member Functions inherited from wangle::InboundHandler< folly::IOBufQueue &, std::string > | |
~InboundHandler () override=default | |
virtual void | readEOF (Context *ctx) |
virtual void | readException (Context *ctx, folly::exception_wrapper e) |
Public Member Functions inherited from wangle::HandlerBase< InboundHandlerContext< std::string > > | |
virtual | ~HandlerBase ()=default |
virtual void | attachPipeline (InboundHandlerContext< std::string > *) |
virtual void | detachPipeline (InboundHandlerContext< std::string > *) |
InboundHandlerContext< std::string > * | getContext () |
Additional Inherited Members | |
Public Types inherited from wangle::ByteToMessageDecoder< std::string > | |
typedef InboundHandler< folly::IOBufQueue &, std::string >::Context | Context |
Public Types inherited from wangle::InboundHandler< folly::IOBufQueue &, std::string > | |
typedef folly::IOBufQueue & | rin |
typedef std::string | rout |
typedef folly::Unit | win |
typedef folly::Unit | wout |
typedef InboundHandlerContext< std::string > | Context |
Static Public Attributes inherited from wangle::InboundHandler< folly::IOBufQueue &, std::string > | |
static const HandlerDir | dir |
Steps to run: 1) Run an upstream server that can broadcast messages:
nc -l localhost 8081
This starts a server on localhost:8081.
2) Start the broadcast proxy with the upstream_port set to 8081:
./broadcast_proxy –port 8080 –upstream_port 8081
This starts the proxy on localhost:8080 and sets the upstream server as localhost:8081
3) Start a new instances of telnet clients to connect to the broadcast proxy and listen to the messages broadcasted by the upstream server:
telnet localhost 8080
Send some bytes in the telnet terminals for broadcast_proxy to kick off the connection.
4) Type something in the nc terminal and notice that it is broadcasted to all the telnet clients. A simple decoder that decodes bytes in IOBufQueue to std::string. This is used in the BroadcastPipeline to convert bytes read from the upstream server's socket to strings of messages that can be broadcasted to all the clients/observers.
Definition at line 69 of file BroadcastProxy.cpp.
|
inlineoverridevirtual |
Decode bytes from buf into result.
Implements wangle::ByteToMessageDecoder< std::string >.
Definition at line 71 of file BroadcastProxy.cpp.
References folly::IOBufQueue::chainLength(), and folly::IOBufQueue::move().