RpcSession.h 795 B

123456789101112131415161718192021222324252627282930313233343536
  1. #ifndef NET_RPC_SESSION_H
  2. #define NET_RPC_SESSION_H
  3. #include <list>
  4. #include <boost/asio.hpp>
  5. #include <boost/array.hpp>
  6. #include <boost/noncopyable.hpp>
  7. #include <boost/shared_ptr.hpp>
  8. #include <boost/enable_shared_from_this.hpp>
  9. namespace Hainan {
  10. class RpcSession: private boost::noncopyable,
  11. public boost::enable_shared_from_this<RpcSession>
  12. {
  13. private:
  14. typedef boost::unordered_set<RpcSessionPtr> RpcSessionSet;
  15. boost::asio::ip::tcp::socket socket;
  16. std::list<RpcResponsePtr> responses;
  17. RpcSessionSet& sessions;
  18. ThreadPool& thread_pool;
  19. public:
  20. RpcSession(RpcSessionSet& rpc_sessions, ThreadPool& pool);
  21. ~RpcSession();
  22. boost::asio::ip::tcp::socket& Socket();
  23. void Start();
  24. void Stop();
  25. };
  26. typedef boost::shared_ptr<RpcSession> RpcSessionPtr;
  27. }
  28. #endif // NET_RPC_SESSION_H