proxygen
TelnetHandler Class Reference
Inheritance diagram for TelnetHandler:
wangle::HandlerAdapter< std::string > wangle::HandlerAdapter< std::string > wangle::Handler< std::string, std::string, std::string, std::string > wangle::Handler< std::string, std::string, std::string, std::string > wangle::HandlerBase< HandlerContext< std::string, std::string > > wangle::HandlerBase< HandlerContext< std::string, std::string > >

Public Member Functions

void read (Context *, std::string msg) override
 
void readException (Context *ctx, exception_wrapper e) override
 
void readEOF (Context *ctx) override
 
void read (Context *ctx, std::string msg) override
 
void transportActive (Context *ctx) override
 
- Public Member Functions inherited from wangle::HandlerAdapter< std::string >
void read (Context *ctx, std::stringmsg) override
 
folly::Future< folly::Unitwrite (Context *ctx, std::stringmsg) override
 
- Public Member Functions inherited from wangle::Handler< std::string, std::string, std::string, std::string >
 ~Handler () override=default
 
virtual void transportInactive (Context *ctx)
 
virtual folly::Future< folly::UnitwriteException (Context *ctx, folly::exception_wrapper e)
 
virtual folly::Future< folly::Unitclose (Context *ctx)
 
- Public Member Functions inherited from wangle::HandlerBase< HandlerContext< std::string, std::string > >
virtual ~HandlerBase ()=default
 
virtual void attachPipeline (HandlerContext< std::string, std::string > *)
 
virtual void detachPipeline (HandlerContext< std::string, std::string > *)
 
HandlerContext< std::string, std::string > * getContext ()
 

Additional Inherited Members

- Public Types inherited from wangle::HandlerAdapter< std::string >
typedef Handler< std::string, std::string, std::string, std::string >::Context Context
 
- Public Types inherited from wangle::Handler< std::string, std::string, std::string, std::string >
typedef std::string rin
 
typedef std::string rout
 
typedef std::string win
 
typedef std::string wout
 
typedef HandlerContext< std::string, std::stringContext
 
- Static Public Attributes inherited from wangle::Handler< std::string, std::string, std::string, std::string >
static const HandlerDir dir
 

Detailed Description

Definition at line 36 of file TelnetClient.cpp.

Member Function Documentation

void TelnetHandler::read ( Context ctx,
std::string  msg 
)
inlineoverridevirtual

Implements wangle::Handler< std::string, std::string, std::string, std::string >.

Definition at line 34 of file TelnetServer.cpp.

References folly::netops::close(), and fizz::detail::write().

34  {
35  if (msg.empty()) {
36  write(ctx, "Please type something.\r\n");
37  } else if (msg == "bye") {
38  write(ctx, "Have a fabulous day!\r\n").thenValue([ctx, this](auto&&) {
39  close(ctx);
40  });
41  } else {
42  write(ctx, "Did you say '" + msg + "'?\r\n");
43  }
44  }
folly::Future< folly::Unit > write(Context *ctx, std::stringmsg) override
Definition: Handler.h:167
virtual folly::Future< folly::Unit > close(Context *ctx)
Definition: Handler.h:79
void TelnetHandler::read ( Context ,
std::string  msg 
)
inlineoverridevirtual

Implements wangle::Handler< std::string, std::string, std::string, std::string >.

Definition at line 38 of file TelnetClient.cpp.

38  {
39  std::cout << msg;
40  }
void TelnetHandler::readEOF ( Context ctx)
inlineoverridevirtual

Reimplemented from wangle::Handler< std::string, std::string, std::string, std::string >.

Definition at line 45 of file TelnetClient.cpp.

References folly::netops::close().

45  {
46  std::cout << "EOF received :(" << std::endl;
47  close(ctx);
48  }
virtual folly::Future< folly::Unit > close(Context *ctx)
Definition: Handler.h:79
void TelnetHandler::readException ( Context ctx,
exception_wrapper  e 
)
inlineoverridevirtual

Reimplemented from wangle::Handler< std::string, std::string, std::string, std::string >.

Definition at line 41 of file TelnetClient.cpp.

References folly::netops::close(), and folly::exceptionStr().

41  {
42  std::cout << exceptionStr(e) << std::endl;
43  close(ctx);
44  }
fbstring exceptionStr(const std::exception &e)
virtual folly::Future< folly::Unit > close(Context *ctx)
Definition: Handler.h:79
void TelnetHandler::transportActive ( Context ctx)
inlineoverridevirtual

Reimplemented from wangle::Handler< std::string, std::string, std::string, std::string >.

Definition at line 46 of file TelnetServer.cpp.

References folly::SocketAddress::describe(), wangle::HandlerContext< In, Out >::getTransport(), and fizz::detail::write().

46  {
47  auto sock = ctx->getTransport();
48  SocketAddress localAddress;
49  sock->getLocalAddress(&localAddress);
50  write(ctx, "Welcome to " + localAddress.describe() + "!\r\n");
51  write(ctx, "Type 'bye' to disconnect.\r\n");
52  }
std::string describe() const
folly::Future< folly::Unit > write(Context *ctx, std::stringmsg) override
Definition: Handler.h:167

The documentation for this class was generated from the following files: