MACE
1.0.0
|
00001 #ifndef _MACE_RPC_RAW_TCP_DETAIL_CONNECTION_HPP 00002 #define _MACE_RPC_RAW_TCP_DETAIL_CONNECTION_HPP 00003 #include <mace/rpc/tcp/detail/connection.hpp> 00004 #include <mace/rpc/raw/message.hpp> 00005 #include <mace/rpc/raw/raw_io.hpp> 00006 00007 namespace mace { namespace rpc { namespace raw { namespace tcp { namespace detail { 00008 00009 class connection : public mace::rpc::tcp::detail::connection { 00010 public: 00011 connection(){} 00012 00013 connection( const boost::asio::ip::tcp::endpoint& ep ) 00014 :mace::rpc::tcp::detail::connection(ep) {} 00015 00016 connection( const mace::cmt::asio::tcp::socket::ptr& sock ) 00017 :mace::rpc::tcp::detail::connection(sock) {} 00018 00019 virtual void send_message( rpc::message&& m ) { 00020 raw::message rm( std::move(m) ); 00021 raw::pack( *m_sock, rm ); 00022 } 00023 virtual rpc::message read_message() { 00024 raw::message rm; 00025 raw::unpack( *m_sock, rm ); 00026 slog( "unpacked id: %1% method: %2% error: %3% datalen: %4%", rm.id.value, rm.method, rm.error_code.value, rm.data.size() ); 00027 00028 return static_cast<rpc::message>(rm); 00029 } 00030 }; 00031 00032 } } } } } // mace::rpc::raw::tcp::deatil 00033 00034 #endif // _MACE_RPC_RAW_TCP_DETAIL_CONNECTION_HPP