#ifndef NET_RPC_SERVER_H #define NET_RPC_SERVER_H #include #include "base/base.h" namespace Egametang { class RpcServer: public boost::enable_shared_from_this { private: typedef boost::unordered_set RpcSessionSet; google::protobuf::Service& service_; boost::asio::io_service& io_service_; boost::asio::ip::tcp::acceptor acceptor_; ThreadPoolIf& thread_pool_; RpcSessionSet sessions_; void HandleAsyncAccept(RpcSessionPtr session, const boost::system::error_code& err); void Callback(RpcSessionPtr session, boost::function handler); public: RpcServer(boost::asio::io_service& io_service, int port, ThreadPool& thread_pool); ~RpcServer(); void Start(); void Stop(); void RunService(RpcSessionPtr session, RpcRequestPtr request, boost::function handler); void RegisterService(ProtobufServicePtr service); }; } // namespace Egametang #endif // NET_RPC_SERVER_H