peerplays-fc/include/fc/json_rpc_ssh_process_client.hpp

34 lines
1.1 KiB
C++
Raw Normal View History

2012-11-12 03:05:49 +00:00
#pragma once
#include <fc/json_rpc_client.hpp>
2012-11-16 22:13:12 +00:00
#include <fc/json_rpc_stream_connection.hpp>
2012-11-12 03:05:49 +00:00
#include <fc/ssh/process.hpp>
namespace fc { namespace json {
template<typename InterfaceType>
2012-11-16 22:13:12 +00:00
class rpc_ssh_process_client : public rpc_client<InterfaceType> {
2012-11-12 03:05:49 +00:00
public:
rpc_ssh_process_client(){}
bool valid()const { return proc.valid(); }
rpc_ssh_process_client( const fc::ssh::process& proc )
2012-11-16 22:13:12 +00:00
:rpc_client<InterfaceType>(rpc_connection::ptr(new fc::json::rpc_stream_connection( proc.out_stream(), proc.in_stream() ) ) ){}
2012-11-12 03:05:49 +00:00
rpc_ssh_process_client& operator = ( const fc::ssh::process& proc ) {
2012-11-16 22:13:12 +00:00
this->set_connection( rpc_connection::ptr(new fc::json::rpc_stream_connection( proc.out_stream(), proc.in_stream() ) ) );
2012-11-12 03:05:49 +00:00
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;
};
} }