Merge commit '72288a2'
This commit is contained in:
commit
3599850bb9
3 changed files with 20 additions and 12 deletions
|
|
@ -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();
|
||||
});
|
||||
|
|
|
|||
|
|
@ -1,5 +1,6 @@
|
|||
|
||||
#include <fc/rpc/cli.hpp>
|
||||
#include <fc/thread/thread.hpp>
|
||||
|
||||
#include <iostream>
|
||||
|
||||
|
|
@ -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
|
||||
|
|
|
|||
|
|
@ -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<void(int32_t)>& cb );
|
||||
void on_result2( const std::function<void(int32_t)>& 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<void(int32_t)>& cb ) { wlog( "set callback" ); _cb = cb; return ; }
|
||||
void on_result2( const std::function<void(int32_t)>& cb, int test ){}
|
||||
std::function<void(int32_t)> _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<void(int32_t)>& cb ) { wlog("set callback"); _cb = cb; return ; }
|
||||
void on_result2( const std::function<void(int32_t)>& cb, int test ){}
|
||||
std::function<void(int32_t)> _cb;
|
||||
};
|
||||
|
||||
|
|
|
|||
Loading…
Reference in a new issue