multi-param json-rpc, fix multi-request
This commit is contained in:
parent
031e2db4db
commit
98f4b7026d
4 changed files with 6 additions and 11 deletions
|
|
@ -25,7 +25,6 @@ namespace fc { namespace json {
|
|||
template<typename T>
|
||||
struct pending_result_impl : virtual public promise<T>, virtual public pending_result {
|
||||
virtual void handle_result( const fc::value& s ) {
|
||||
slog( "cast %s", typeid(T).name() );
|
||||
this->set_value( value_cast<T>(s) );
|
||||
}
|
||||
protected:
|
||||
|
|
|
|||
|
|
@ -6,15 +6,9 @@ namespace fc {
|
|||
|
||||
namespace detail {
|
||||
struct identity_member {
|
||||
// TODO: enumerate all method patterns
|
||||
template<typename R, typename C, typename P>
|
||||
static fc::function<R> functor( P&& p, R (C::*mem_func)() ) {
|
||||
return [=](){ return (p->*mem_func)(); };
|
||||
}
|
||||
|
||||
template<typename R, typename C, typename A1, typename P>
|
||||
static fc::function<R,A1> functor( P&& p, R (C::*mem_func)(A1) ) {
|
||||
return fc::function<R,A1>([=](A1 a1){ return (p->*mem_func)(a1); });
|
||||
template<typename R, typename C, typename P, typename... Args>
|
||||
static fc::function<R,Args...> functor( P&& p, R (C::*mem_func)(Args...) ) {
|
||||
return fc::function<R,Args...>([=](Args... args){ return (p->*mem_func)(args...); });
|
||||
}
|
||||
};
|
||||
|
||||
|
|
|
|||
|
|
@ -140,6 +140,7 @@ namespace fc { namespace json {
|
|||
|
||||
void rpc_connection::invoke( detail::pending_result::ptr&& p,
|
||||
const fc::string& m, value&& param ) {
|
||||
p->id = my->_next_req_id;
|
||||
if( my->_pr_tail ) {
|
||||
my->_pr_tail->next = p;
|
||||
my->_pr_tail = my->_pr_tail->next;
|
||||
|
|
|
|||
|
|
@ -10,7 +10,7 @@ struct test {
|
|||
int sub(int x){ return x-1; }
|
||||
int sub1(int x){ return 3; }
|
||||
int sub2(float x){ return 3; }
|
||||
int sub3(double x){ return 3; }
|
||||
int sub3(double x, int y){ return x-y; }
|
||||
int sub4(uint16_t x){ return 3; }
|
||||
int sub5(char x){ return 3; }
|
||||
int sub6(uint64_t x){ return 3; }
|
||||
|
|
@ -37,6 +37,7 @@ int main( int argc, char** argv ) {
|
|||
|
||||
fc::json::rpc_client<test> rpcc( con );
|
||||
slog( "5+1=%d", rpcc->add(5).wait() );
|
||||
slog( "sub3 4-5=%d", rpcc->sub3(4,5).wait() );
|
||||
}
|
||||
slog( "exit serv" );
|
||||
/*
|
||||
|
|
|
|||
Loading…
Reference in a new issue