MACE
1.0.0
|
00001 #ifndef _MACE_RPC_JSON_HTTP_SERVER_HPP_ 00002 #define _MACE_RPC_JSON_HTTP_SERVER_HPP_ 00003 #include <mace/stub/ptr.hpp> 00004 #include <mace/rpc/json/connection.hpp> 00005 #include <boost/any.hpp> 00006 00007 namespace mace { namespace rpc { namespace json { 00008 00013 class http_server { 00014 public: 00015 http_server( const std::string& ip, uint16_t port, uint16_t threads = 2 ); 00016 ~http_server(); 00017 00018 template<typename InterfaceType, typename T> 00019 void add_service( const std::string& path, const boost::shared_ptr<T>& s ); 00020 00025 void add_service( const std::string& path, const rpc::json::connection::ptr& c, const boost::any& s = boost::any() ); 00026 00027 private: 00028 class http_server_private* my; 00029 }; 00030 00031 00032 template<typename InterfaceType, typename T> 00033 void http_server::add_service( const std::string& path, const boost::shared_ptr<T>& s ) { 00034 mace::stub::ptr<InterfaceType> session(s); 00035 json::connection::ptr con = boost::make_shared<rpc::json::connection>(); 00036 mace::stub::visit( session, add_interface_visitor<InterfaceType>( *con, session ) ); 00037 add_service( path, con, session ); 00038 } 00039 00040 } } } // mace::rpc::json::http 00041 00042 #endif