MACE  1.0.0
 All Classes Namespaces Files Functions Variables Enumerations Defines
libs/rpc/include/mace/rpc/http/connection.hpp
00001 #ifndef _MACE_RPC_HTTP_CONNECTION_HPP_
00002 #define _MACE_RPC_HTTP_CONNECTION_HPP_
00003 #include <mace/rpc/tcp/connection.hpp>
00004 #include <mace/rpc/http/detail/connection.hpp>
00005 
00006 namespace mace { namespace rpc { namespace http {
00007   class request;
00008   class reply;
00009 
00016   template<typename IODelegate=mace::rpc::raw_io>
00017   class connection : public mace::rpc::tcp::connection<IODelegate> {
00018     public:
00019       typedef boost::shared_ptr<connection> ptr;
00020 
00021       template<typename String>
00022       connection( String&& host, uint16_t port = 80 )
00023       :rpc::tcp::connection<IODelegate>( 
00024         new mace::rpc::http::detail::connection(std::forward<String>(host),port) ) {}
00025 
00026       connection( const boost::asio::ip::tcp::endpoint& ep )
00027       :rpc::tcp::connection<IODelegate>( new mace::rpc::http::detail::connection(ep) ){}
00028 
00029       connection( const mace::cmt::asio::tcp::socket::ptr& sock )
00030       :rpc::tcp::connection<IODelegate>( new mace::rpc::http::detail::connection(sock) ) {}
00031 
00032       reply send( request&& r ) {
00033         return static_cast<mace::rpc::http::detail::connection*>(this->my)->send( std::move(r) );
00034       }
00035 
00036     protected:
00037       connection( mace::rpc::http::detail::connection* b )
00038       :rpc::tcp::connection<IODelegate>(b){}
00039   };
00040 
00041 } } } // mace::rpc::http
00042 
00043 #endif // _MACE_RPC_HTTP_CONNECTION_HPP_