#ifndef MUDUO_CONTRIB_THRIFT_THRIFTCONNECTION_H #define MUDUO_CONTRIB_THRIFT_THRIFTCONNECTION_H #include #include #include "muduo/net/TcpConnection.h" #include #include #include using apache::thrift::TProcessor; using apache::thrift::protocol::TProtocol; using apache::thrift::transport::TMemoryBuffer; using apache::thrift::transport::TNullTransport; using apache::thrift::transport::TTransport; using apache::thrift::transport::TTransportException; class ThriftServer; class ThriftConnection : boost::noncopyable, public boost::enable_shared_from_this { public: enum State { kExpectFrameSize, kExpectFrame }; ThriftConnection(ThriftServer* server, const muduo::net::TcpConnectionPtr& conn); private: void onMessage(const muduo::net::TcpConnectionPtr& conn, muduo::net::Buffer* buffer, muduo::Timestamp receiveTime); void process(); void close(); private: ThriftServer* server_; muduo::net::TcpConnectionPtr conn_; boost::shared_ptr nullTransport_; boost::shared_ptr inputTransport_; boost::shared_ptr outputTransport_; boost::shared_ptr factoryInputTransport_; boost::shared_ptr factoryOutputTransport_; boost::shared_ptr inputProtocol_; boost::shared_ptr outputProtocol_; boost::shared_ptr processor_; enum State state_; uint32_t frameSize_; }; typedef boost::shared_ptr ThriftConnectionPtr; #endif // MUDUO_CONTRIB_THRIFT_THRIFTCONNECTION_H