RpcSession.h 1.0 KB

1234567891011121314151617181920212223242526272829303132333435363738
  1. #ifndef NET_RPC_SESSION_H
  2. #define NET_RPC_SESSION_H
  3. #include <boost/asio.hpp>
  4. #include <boost/array.hpp>
  5. #include <boost/noncopyable.hpp>
  6. #include <boost/shared_ptr.hpp>
  7. #include <boost/enable_shared_from_this.hpp>
  8. namespace Egametang {
  9. class RpcServer;
  10. class RpcSession: private boost::noncopyable, public boost::enable_shared_from_this<RpcSession>
  11. {
  12. private:
  13. boost::asio::ip::tcp::socket socket_;
  14. RpcServer& rpc_server_;
  15. void RecvMessegeSize();
  16. void RecvMessage(IntPtr size, const boost::system::error_code& err);
  17. void RecvMessageHandler(StringPtr ss, const boost::system::error_code& err);
  18. void SendMessageSize(RpcResponsePtr response);
  19. void SendMessage(const RpcResponsePtr response, const boost::system::error_code& err);
  20. void SendMessageHandler(int32 id, RpcHandlerPtr handler, const boost::system::error_code& err);
  21. public:
  22. RpcSession(RpcServer& server);
  23. ~RpcSession();
  24. boost::asio::ip::tcp::socket& Socket();
  25. void Start();
  26. void Stop();
  27. };
  28. } // namespace Egametang
  29. #endif // NET_RPC_SESSION_H