diff --git a/src/network/http/websocket.cpp b/src/network/http/websocket.cpp index 5987027..283730b 100644 --- a/src/network/http/websocket.cpp +++ b/src/network/http/websocket.cpp @@ -73,6 +73,7 @@ namespace fc { namespace http { virtual void send_message( const std::string& message )override { + idump((message)); auto ec = _ws_connection->send( message ); FC_ASSERT( !ec, "websocket send failed: ${msg}", ("msg",ec.message() ) ); } @@ -103,7 +104,7 @@ namespace fc { namespace http { _server_thread.async( [&](){ auto current_con = _connections.find(hdl); assert( current_con != _connections.end() ); - //wdump(("server")(msg->get_payload())); + wdump(("server")(msg->get_payload())); current_con->second->on_message( msg->get_payload() ); }).wait(); }); @@ -154,7 +155,7 @@ namespace fc { namespace http { _client.clear_access_channels( websocketpp::log::alevel::all ); _client.set_message_handler( [&]( connection_hdl hdl, message_ptr msg ){ _client_thread.async( [&](){ - // wdump((msg->get_payload())); + wdump((msg->get_payload())); _connection->on_message( msg->get_payload() ); }).wait(); }); diff --git a/src/rpc/cli.cpp b/src/rpc/cli.cpp index 1525cb2..fd441e4 100644 --- a/src/rpc/cli.cpp +++ b/src/rpc/cli.cpp @@ -1,5 +1,6 @@ #include +#include #include @@ -49,15 +50,18 @@ void cli::getline( if( _isatty( _fileno( stdin ) ) ) #endif { - char* line_read = nullptr; - std::cout.flush(); //readline doesn't use cin, so we must manually flush _out - line_read = readline(prompt.c_str()); - if( line_read == nullptr ) - FC_THROW_EXCEPTION( fc::eof_exception, "" ); - if( *line_read ) - add_history(line_read); - line = line_read; - free(line_read); + static fc::thread getline_thread("getline"); + getline_thread.async( [&](){ + char* line_read = nullptr; + std::cout.flush(); //readline doesn't use cin, so we must manually flush _out + line_read = readline(prompt.c_str()); + if( line_read == nullptr ) + FC_THROW_EXCEPTION( fc::eof_exception, "" ); + if( *line_read ) + add_history(line_read); + line = line_read; + free(line_read); + }).wait(); } else #endif diff --git a/tests/api.cpp b/tests/api.cpp index 533e52b..4fcd8b5 100644 --- a/tests/api.cpp +++ b/tests/api.cpp @@ -9,9 +9,10 @@ class calculator int32_t add( int32_t a, int32_t b ); // not implemented int32_t sub( int32_t a, int32_t b ); // not implemented void on_result( const std::function& cb ); + void on_result2( const std::function& cb, int test ); }; -FC_API( calculator, (add)(sub)(on_result) ) +FC_API( calculator, (add)(sub)(on_result)(on_result2) ) class login_api @@ -35,6 +36,7 @@ class some_calculator int32_t add( int32_t a, int32_t b ) { wlog("."); if( _cb ) _cb(a+b); return a+b; } int32_t sub( int32_t a, int32_t b ) { wlog(".");if( _cb ) _cb(a-b); return a-b; } void on_result( const std::function& cb ) { wlog( "set callback" ); _cb = cb; return ; } + void on_result2( const std::function& cb, int test ){} std::function _cb; }; class variant_calculator @@ -43,6 +45,7 @@ class variant_calculator double add( fc::variant a, fc::variant b ) { return a.as_double()+b.as_double(); } double sub( fc::variant a, fc::variant b ) { return a.as_double()-b.as_double(); } void on_result( const std::function& cb ) { wlog("set callback"); _cb = cb; return ; } + void on_result2( const std::function& cb, int test ){} std::function _cb; };