RpcSession.cc 889 B

1234567891011121314151617181920212223242526272829303132333435363738394041424344
  1. #include <boost/bind.hpp>
  2. #include <glog/logging.h>
  3. #include "Rpc/RpcSession.h"
  4. #include "Rpc/RpcServer.h"
  5. namespace Egametang {
  6. RpcSession::RpcSession(boost::asio::io_service& ioService, RpcServer& server):
  7. RpcCommunicator(ioService), rpcServer(server)
  8. {
  9. }
  10. RpcSession::~RpcSession()
  11. {
  12. }
  13. void RpcSession::OnRecvMessage(RpcMetaPtr meta, StringPtr message)
  14. {
  15. RpcSessionPtr session = shared_from_this();
  16. rpcServer.RunService(session, meta, message,
  17. boost::bind(&RpcSession::SendMeta, session, _1, _2));
  18. // 可以循环利用
  19. RecvMeta(meta, message);
  20. }
  21. void RpcSession::OnSendMessage(RpcMetaPtr meta, StringPtr message)
  22. {
  23. }
  24. void RpcSession::Start()
  25. {
  26. RpcMetaPtr meta(new RpcMeta());
  27. StringPtr message(new std::string);
  28. RecvMeta(meta, message);
  29. }
  30. void RpcSession::Stop()
  31. {
  32. RpcSessionPtr session = shared_from_this();
  33. rpcServer.Remove(session);
  34. }
  35. } // namespace Egametang