diff --git a/include/fc/json_rpc_error_object.hpp b/include/fc/json_rpc_error_object.hpp new file mode 100644 index 0000000..656c150 --- /dev/null +++ b/include/fc/json_rpc_error_object.hpp @@ -0,0 +1,16 @@ +#pragma once + +namespace fc { namespace json { + + struct error_object { + error_object( const fc::string& msg = fc::string(), fc::value v = fc::value(), int64_t c = -32000); + + int64_t code; + fc::string message; + fc::optional data; + }; + +} } + +#include +FC_REFLECT( fc::json::error_object, (code)(message)(data) ) diff --git a/include/fc/json_rpc_ssh_process_client.hpp b/include/fc/json_rpc_ssh_process_client.hpp new file mode 100644 index 0000000..d11018b --- /dev/null +++ b/include/fc/json_rpc_ssh_process_client.hpp @@ -0,0 +1,38 @@ +#pragma once +#include +#include + +namespace fc { namespace json { + + template + class rpc_ssh_process_client : public ptr { + public: + rpc_ssh_process_client(){} + bool valid()const { return proc.valid(); } + + rpc_ssh_process_client( const fc::ssh::process& proc ) + { + con.reset( new fc::json::rpc_stream_connection( proc.out_stream(), proc.in_stream() ) ); + this->_vtable.reset(new fc::detail::vtable() ); + this->_vtable->template visit( fc::json::detail::vtable_visitor(_con) ); + } + + rpc_ssh_process_client& operator = ( const fc::ssh::process& proc ) { + con.reset( new fc::json::rpc_stream_connection( proc.out_stream(), proc.in_stream() ) ); + this->_vtable.reset(new fc::detail::vtable() ); + this->_vtable->template visit( fc::json::detail::vtable_visitor(_con) ); + return *this; + } + + /** + * @brief returns a stream that reads from the process' stderr + */ + fc::istream& err_stream() { return proc.err_stream(); } + + fc::ssh::process& get_ssh_process() { return proc; } + private: + fc::ssh::process proc; + fc::json::rpc_stream_connection::ptr _con; + + }; +} } diff --git a/src/json_rpc_error_object.cpp b/src/json_rpc_error_object.cpp new file mode 100644 index 0000000..3fc186d --- /dev/null +++ b/src/json_rpc_error_object.cpp @@ -0,0 +1,6 @@ +#include + +namespace fc { namespace json { + error_object::error_object( const fc::string& msg, fc::value v, int c ) + :code(c),message(m),data(fc::move(v)){} +}}