updates...
This commit is contained in:
parent
44ea53407b
commit
949095ab00
8 changed files with 30 additions and 11 deletions
|
|
@ -50,6 +50,7 @@ set( sources
|
|||
src/ssh.cpp
|
||||
src/process.cpp
|
||||
src/http_connection.cpp
|
||||
src/http_server.cpp
|
||||
src/json_rpc_connection.cpp
|
||||
src/json_rpc_stream_connection.cpp
|
||||
src/json_rpc_tcp_connection.cpp
|
||||
|
|
|
|||
|
|
@ -47,10 +47,9 @@ namespace fc {
|
|||
http::reply request( const fc::string& method, const fc::string& url, const fc::string& body );
|
||||
|
||||
// used for servers
|
||||
fc::tcp_socket& get_socket();
|
||||
fc::tcp_socket& get_socket()const;
|
||||
|
||||
http::request read_request();
|
||||
void send_reply( const http::reply& );
|
||||
http::request read_request()const;
|
||||
|
||||
FC_REFERENCE_TYPE(connection)
|
||||
};
|
||||
|
|
|
|||
|
|
@ -14,6 +14,8 @@ shared_impl<T>::shared_impl( U&& u ):_impl(fc::forward<U>(u)){}
|
|||
|
||||
template<typename T>
|
||||
shared_impl<T>::shared_impl( const shared_impl<T>& u ):_impl(u._impl){}
|
||||
template<typename T>
|
||||
shared_impl<T>::shared_impl( shared_impl<T>& u ):_impl(u._impl){}
|
||||
|
||||
template<typename T>
|
||||
shared_impl<T>::shared_impl( shared_impl<T>&& u ):_impl(fc::move(u._impl)){}
|
||||
|
|
@ -55,6 +57,8 @@ TYPE::TYPE( TYPE&& c )\
|
|||
:my(fc::move(c.my)){}\
|
||||
TYPE::TYPE( const TYPE& c )\
|
||||
:my(c.my){}\
|
||||
TYPE::TYPE( TYPE& c )\
|
||||
:my(c.my){}\
|
||||
TYPE::TYPE() \
|
||||
:my( new fc::shared_impl<TYPE>::impl( ) ){}\
|
||||
TYPE::~TYPE(){}\
|
||||
|
|
|
|||
|
|
@ -113,6 +113,7 @@ namespace fc {
|
|||
shared_impl( U&& u );
|
||||
|
||||
shared_impl( const shared_impl& u );
|
||||
shared_impl( shared_impl& u );
|
||||
shared_impl( shared_impl&& u );
|
||||
shared_impl& operator=( shared_impl&& u );
|
||||
shared_impl& operator=( const shared_impl& u );
|
||||
|
|
@ -131,6 +132,7 @@ namespace fc {
|
|||
TYPE( TYPE* ); \
|
||||
TYPE( TYPE&& ); \
|
||||
TYPE( const TYPE& ); \
|
||||
TYPE( TYPE& ); \
|
||||
template<typename A1> \
|
||||
TYPE( A1&& ); \
|
||||
template<typename A1,typename A2> \
|
||||
|
|
|
|||
|
|
@ -40,6 +40,10 @@ namespace fc {
|
|||
_ptr = p._ptr;
|
||||
if( _ptr ) _ptr->retain();
|
||||
}
|
||||
shared_ptr( shared_ptr& p ) {
|
||||
_ptr = p._ptr;
|
||||
if( _ptr ) _ptr->retain();
|
||||
}
|
||||
shared_ptr( shared_ptr&& p ) {
|
||||
_ptr = p._ptr;
|
||||
p._ptr = nullptr;
|
||||
|
|
|
|||
|
|
@ -93,16 +93,19 @@ namespace fc {
|
|||
*/
|
||||
template<typename T>
|
||||
inline void pack_helper( const T& v, const char* name )const {
|
||||
slog( "%s", name );
|
||||
fc::pack( obj[name], v );
|
||||
}
|
||||
template<typename T>
|
||||
inline void pack_helper( const fc::optional<T>& v, const char* name )const {
|
||||
slog( "%s", name );
|
||||
if( !!v ) {
|
||||
fc::pack( obj[name], *v );
|
||||
}
|
||||
}
|
||||
template<typename T, typename C, T (C::*p)>
|
||||
inline void operator()( const char* name )const {
|
||||
slog( "%s", name );
|
||||
pack_helper( c.*p, name );
|
||||
}
|
||||
|
||||
|
|
|
|||
|
|
@ -114,16 +114,13 @@ http::reply connection::request( const fc::string& method,
|
|||
}
|
||||
|
||||
// used for servers
|
||||
fc::tcp_socket& connection::get_socket() {
|
||||
fc::tcp_socket& connection::get_socket()const {
|
||||
return my->sock;
|
||||
}
|
||||
|
||||
http::request connection::read_request() {
|
||||
http::request connection::read_request()const {
|
||||
http::request r;
|
||||
return r;
|
||||
}
|
||||
void connection::send_reply( const http::reply& ) {
|
||||
|
||||
}
|
||||
|
||||
} } // fc::http
|
||||
|
|
|
|||
|
|
@ -9,7 +9,7 @@ namespace fc {
|
|||
|
||||
class tcp_socket::impl {
|
||||
public:
|
||||
impl():_sock( fc::asio::default_io_service() ){ }
|
||||
impl():_sock( fc::asio::default_io_service() ){ slog( "creating socket %p", &_sock); }
|
||||
~impl(){
|
||||
if( _sock.is_open() ) _sock.close();
|
||||
}
|
||||
|
|
@ -85,7 +85,10 @@ namespace fc {
|
|||
|
||||
class tcp_server::impl {
|
||||
public:
|
||||
impl(uint16_t port):_accept( fc::asio::default_io_service(), boost::asio::ip::tcp::endpoint(boost::asio::ip::tcp::v4(), port) ){}
|
||||
impl(uint16_t port):
|
||||
_accept( fc::asio::default_io_service(), boost::asio::ip::tcp::endpoint(boost::asio::ip::tcp::v4(), port) ){
|
||||
slog( "... tcp server port %d", port );
|
||||
}
|
||||
~impl(){
|
||||
_accept.close();
|
||||
}
|
||||
|
|
@ -105,17 +108,23 @@ namespace fc {
|
|||
|
||||
|
||||
bool tcp_server::accept( tcp_socket& s ) {
|
||||
fc::promise<boost::system::error_code>::ptr p( new promise<boost::system::error_code>("mace::cmt::asio::tcp::accept") );
|
||||
fc::promise<boost::system::error_code>::ptr p( new promise<boost::system::error_code>("tcp::accept") );
|
||||
slog( "accept socket %p", &s.my->_sock );
|
||||
my->_accept.async_accept( s.my->_sock, [=]( const boost::system::error_code& e ) {
|
||||
p->set_value(e);
|
||||
} );
|
||||
slog( ".");
|
||||
auto ec = p->wait();
|
||||
slog( ".");
|
||||
if( !ec ) s.my->_sock.non_blocking(true);
|
||||
slog( ".");
|
||||
if( ec ) BOOST_THROW_EXCEPTION( boost::system::system_error(ec) );
|
||||
slog( ".");
|
||||
return true;
|
||||
}
|
||||
void tcp_server::listen( uint16_t port ) {
|
||||
if( my ) delete my;
|
||||
slog( "Listen %d", port );
|
||||
my = new impl(port);
|
||||
}
|
||||
|
||||
|
|
|
|||
Loading…
Reference in a new issue