adding support for 7 arg rpc calls
This commit is contained in:
parent
d046526974
commit
17117bc6bf
3 changed files with 59 additions and 4 deletions
|
|
@ -326,17 +326,19 @@ do { if( !(TEST) ) { FC_THROW_EXCEPTION( fc::assert_exception, #TEST ": " __VA_
|
||||||
FC_LOG_MESSAGE( LOG_LEVEL, FORMAT,__VA_ARGS__), \
|
FC_LOG_MESSAGE( LOG_LEVEL, FORMAT,__VA_ARGS__), \
|
||||||
std::current_exception() ); \
|
std::current_exception() ); \
|
||||||
}
|
}
|
||||||
#define FC_CAPTURE_AND_RETHROW( SEQ ) \
|
|
||||||
|
#define FC_CAPTURE_AND_RETHROW( __VA_ARGS__ ) \
|
||||||
catch( fc::exception& er ) { \
|
catch( fc::exception& er ) { \
|
||||||
FC_RETHROW_EXCEPTION( er, fc::log_level::warn, "", FC_FORMAT_ARG_PARAMS(SEQ) ); \
|
FC_RETHROW_EXCEPTION( er, warn, "", FC_FORMAT_ARG_PARAMS(__VA_ARGS__) ); \
|
||||||
} catch( const std::exception& e ) { \
|
} catch( const std::exception& e ) { \
|
||||||
fc::exception fce( \
|
fc::exception fce( \
|
||||||
FC_LOG_MESSAGE( fc::log_level::warn, "${what}",FC_FORMAT_ARG_PARAMS(SEQ)("what",e.what())), \
|
FC_LOG_MESSAGE( warn, "${what}",FC_FORMAT_ARG_PARAMS(__VA_ARGS__)("what",e.what())), \
|
||||||
fc::std_exception_code,\
|
fc::std_exception_code,\
|
||||||
typeid(e).name(), \
|
typeid(e).name(), \
|
||||||
e.what() ) ; throw fce;\
|
e.what() ) ; throw fce;\
|
||||||
} catch( ... ) { \
|
} catch( ... ) { \
|
||||||
throw fc::unhandled_exception( \
|
throw fc::unhandled_exception( \
|
||||||
FC_LOG_MESSAGE( fc::log_level::warn, "",FC_FORMAT_ARG_PARAMS(SEQ)), \
|
FC_LOG_MESSAGE( warn, "",FC_FORMAT_ARG_PARAMS(__VA_ARGS__)), \
|
||||||
std::current_exception() ); \
|
std::current_exception() ); \
|
||||||
}
|
}
|
||||||
|
|
||||||
|
|
|
||||||
|
|
@ -97,6 +97,16 @@ namespace fc { namespace rpc {
|
||||||
const variant& a5,
|
const variant& a5,
|
||||||
const variant& a6 );
|
const variant& a6 );
|
||||||
|
|
||||||
|
future<variant> async_call( const fc::string& method,
|
||||||
|
const variant& a1,
|
||||||
|
const variant& a2,
|
||||||
|
const variant& a3,
|
||||||
|
const variant& a4,
|
||||||
|
const variant& a5,
|
||||||
|
const variant& a6,
|
||||||
|
const variant& a7
|
||||||
|
);
|
||||||
|
|
||||||
template<typename Result>
|
template<typename Result>
|
||||||
Result call( const fc::string& method,
|
Result call( const fc::string& method,
|
||||||
const variant& a1,
|
const variant& a1,
|
||||||
|
|
@ -142,6 +152,19 @@ namespace fc { namespace rpc {
|
||||||
{
|
{
|
||||||
return async_call( method, a1, a2, a3, a4, a5, a6).wait(timeout).as<Result>();
|
return async_call( method, a1, a2, a3, a4, a5, a6).wait(timeout).as<Result>();
|
||||||
}
|
}
|
||||||
|
template<typename Result>
|
||||||
|
Result call( const fc::string& method,
|
||||||
|
const variant& a1,
|
||||||
|
const variant& a2,
|
||||||
|
const variant& a3,
|
||||||
|
const variant& a4,
|
||||||
|
const variant& a5,
|
||||||
|
const variant& a6,
|
||||||
|
const variant& a7,
|
||||||
|
microseconds timeout = microseconds::maximum())
|
||||||
|
{
|
||||||
|
return async_call( method, a1, a2, a3, a4, a5, a6,7).wait(timeout).as<Result>();
|
||||||
|
}
|
||||||
|
|
||||||
template<typename Result>
|
template<typename Result>
|
||||||
Result call( const fc::string& method,
|
Result call( const fc::string& method,
|
||||||
|
|
|
||||||
|
|
@ -488,6 +488,36 @@ namespace fc { namespace rpc {
|
||||||
my->_out->flush();
|
my->_out->flush();
|
||||||
return my->_awaiting[id];
|
return my->_awaiting[id];
|
||||||
}
|
}
|
||||||
|
future<variant> json_connection::async_call( const fc::string& method, const variant& a1, const variant& a2, const variant& a3, const variant& a4, const variant& a5, const variant& a6, const variant& a7 )
|
||||||
|
{
|
||||||
|
auto id = my->_next_id++;
|
||||||
|
my->_awaiting[id] = fc::promise<variant>::ptr( new fc::promise<variant>() );
|
||||||
|
|
||||||
|
{
|
||||||
|
fc::scoped_lock<fc::mutex> lock(my->_write_mutex);
|
||||||
|
*my->_out << "{\"id\":";
|
||||||
|
*my->_out << id;
|
||||||
|
*my->_out << ",\"method\":";
|
||||||
|
json::to_stream( *my->_out, method );
|
||||||
|
*my->_out << ",\"params\":[";
|
||||||
|
fc::json::to_stream( *my->_out, a1 );
|
||||||
|
*my->_out << ",";
|
||||||
|
fc::json::to_stream( *my->_out, a2 );
|
||||||
|
*my->_out << ",";
|
||||||
|
fc::json::to_stream( *my->_out, a3 );
|
||||||
|
*my->_out << ",";
|
||||||
|
fc::json::to_stream( *my->_out, a4 );
|
||||||
|
*my->_out << ",";
|
||||||
|
fc::json::to_stream( *my->_out, a5 );
|
||||||
|
*my->_out << ",";
|
||||||
|
fc::json::to_stream( *my->_out, a6 );
|
||||||
|
*my->_out << ",";
|
||||||
|
fc::json::to_stream( *my->_out, a7 );
|
||||||
|
*my->_out << "]}\n";
|
||||||
|
}
|
||||||
|
my->_out->flush();
|
||||||
|
return my->_awaiting[id];
|
||||||
|
}
|
||||||
|
|
||||||
future<variant> json_connection::async_call( const fc::string& method, mutable_variant_object named_args )
|
future<variant> json_connection::async_call( const fc::string& method, mutable_variant_object named_args )
|
||||||
{
|
{
|
||||||
|
|
|
||||||
Loading…
Reference in a new issue