4namespace fc {
namespace rpc {
15 FC_ASSERT( args.size() == 3 && args[2].is_array() );
17 if( args[0].is_string() )
20 subargs.push_back( args[0] );
25 api_id = args[0].as_uint64();
30 args[2].get_array() );
35 FC_ASSERT( args.size() == 2 && args[1].is_array() );
42 FC_ASSERT( args.size() == 2 && args[1].is_array() );
62 auto request =
_rpc_state.start_remote_call(
"call", {api_id, std::move(method_name), std::move(args) } );
64 return _rpc_state.wait_for_response( *request.id );
71 auto request =
_rpc_state.start_remote_call(
"callback", {callback_id, std::move(args) } );
73 return _rpc_state.wait_for_response( *request.id );
80 fc::rpc::request req{ std::optional<uint64_t>(),
"notice", {callback_id, std::move(args)}};
85 const std::string& message,
90 auto handle_error = [&](
const auto& e)
92 wdump((e.to_detail_string()));
93 return e.to_detail_string();
99 const auto& var_obj = var.get_object();
100 if( var_obj.contains(
"method" ) )
102 auto call = var.
as<fc::rpc::request>();
105 auto handle_error_inner = [&](
const auto& e)
112 return e.dynamic_copy_exception();
126 catch (
const std::bad_alloc& )
130 catch (
const boost::interprocess::bad_alloc& )
136 optexcept = handle_error_inner(e);
138 catch (
const std::exception& e )
145 auto reply =
fc::json::to_string( response( *
call.id, error_object{ 1, optexcept->to_detail_string(), fc::variant(*optexcept)} ) );
154 auto reply = var.as<fc::rpc::response>();
158 catch (
const std::bad_alloc& )
162 catch (
const boost::interprocess::bad_alloc& )
168 return handle_error(e);
170 catch (
const std::exception& e)
variant receive_callback(uint64_t callback_id, const variants &args=variants()) const
fc::signal< void()> closed
void receive_notice(uint64_t callback_id, const variants &args=variants()) const
variant receive_call(api_id_type api_id, const string &method_name, const variants &args=variants()) const
Used to generate a useful error report when an exception is thrown.
static string to_string(const variant &v, const yield_function_t &yield, const output_formatting format=output_formatting::stringify_large_ints_and_doubles)
static variant from_string(const string &utf8_str, const parse_type ptype=parse_type::legacy_parser, uint32_t max_depth=DEFAULT_MAX_RECURSION_DEPTH)
fc::rpc::state _rpc_state
std::string on_message(const std::string &message, bool send_message=true)
virtual variant send_call(api_id_type api_id, string method_name, variants args=variants()) override
fc::http::websocket_connection & _connection
virtual variant send_callback(uint64_t callback_id, variants args=variants()) override
websocket_api_connection(fc::http::websocket_connection &c)
virtual void send_notice(uint64_t callback_id, variants args=variants()) override
~websocket_api_connection()
static std_exception_wrapper from_current_exception(const std::exception &e)
stores null, int64, uint64, double, bool, string, std::vector<variant>, and variant_object's.
uint64_t as_uint64() const
#define FC_ASSERT(TEST,...)
Checks a condition and throws an assert_exception if the test is FALSE.
std::shared_ptr< exception > exception_ptr
std::vector< fc::variant > variants
fc::variant call(const std::string &url, const std::string &path, const T &v)
unsigned __int64 uint64_t