MACE
1.0.0
|
00001 #ifndef _MACE_RPC_TCP_CONNECTION_HPP_ 00002 #define _MACE_RPC_TCP_CONNECTION_HPP_ 00003 #include <mace/rpc/connection.hpp> 00004 #include <mace/cmt/asio/tcp/socket.hpp> 00005 #include <mace/rpc/tcp/detail/connection.hpp> 00006 00007 namespace mace { namespace rpc { namespace tcp { 00008 namespace detail { class connection; } 00009 00014 template<typename IODelegate> 00015 class connection : public mace::rpc::connection<IODelegate> { 00016 public: 00017 typedef boost::shared_ptr<connection> ptr; 00018 00019 void close() { this->my->close(); } 00020 00021 void connect( const boost::asio::ip::tcp::endpoint& ep ) { 00022 slog( "this: %1% my: %2%", this, this->my ); 00023 static_cast<mace::rpc::tcp::detail::connection*>(this->my)->connect(ep); 00024 } 00025 00026 void send( message&& m ){ 00027 slog( "this: %1% my: %2%", this, this->my ); 00028 this->my->send( std::move(m) ); 00029 } 00030 protected: 00031 connection( mace::rpc::tcp::detail::connection* m ) 00032 :rpc::connection<IODelegate>(m){} 00033 00034 private: 00035 connection(); 00036 }; 00037 } } } // mace::rpc::tcp 00038 #endif // _MACE_RPC_TCP_CONNECTION_HPP_