Added Multiple Channels and Event support to RPC system.

* added chan_id parameter to many RPC calls, this allows RPC to support multiple SSH clients.
     - the combination of (chan_id, req_id) rather than req_id, should be unique now  
     		-> TODO inside rpcserver queued requests.
 * Modified SSH server to match the new API. Multiple client support has not been added here yet.
 * Modified Menu System to match these changes too.
 * Added an Registration Framework to RpcQueueService, to enable easy event support.
 
This code has not been throughly tested yet.



git-svn-id: http://svn.code.sf.net/p/retroshare/code/branches/v0.5-gxs-b1@5500 b45a01b8-16f6-495d-af2f-9b41ad6348cc
This commit is contained in:
drbob 2012-09-01 19:35:23 +00:00
parent 46c945de96
commit 9c2f7f39e7
17 changed files with 435 additions and 117 deletions

View file

@ -471,7 +471,8 @@ int RsSshd::doRpcSystem()
return 0;
}
mRpcSystem->reset(); // clear everything for new user.
uint32_t dummy_chan_id = 1;
mRpcSystem->reset(dummy_chan_id); // clear everything for new user.
bool okay = true;
while(okay)
@ -511,8 +512,18 @@ int RsSshd::isOkay()
return (mState == RSSSHD_STATE_CONNECTED);
}
std::list<uint32_t>::iterator it;
int RsSshd::active_channels(std::list<uint32_t> &chan_ids)
{
if (isOkay())
{
chan_ids.push_back(1); // dummy for now.
}
int RsSshd::error(std::string msg)
return 1;
}
int RsSshd::error(uint32_t chan_id, std::string msg)
{
std::cerr << "RsSshd::error(" << msg << ")";
std::cerr << std::endl;
@ -522,14 +533,14 @@ int RsSshd::error(std::string msg)
}
int RsSshd::recv_ready()
int RsSshd::recv_ready(uint32_t chan_id)
{
int bytes = ssh_channel_poll(mChannel, 0);
return bytes;
}
int RsSshd::recv(uint8_t *buffer, int bytes)
int RsSshd::recv(uint32_t chan_id, uint8_t *buffer, int bytes)
{
#if LIBSSH_VERSION_INT >= SSH_VERSION_INT(0,5,0)
int size = ssh_channel_read_nonblocking(mChannel, buffer, bytes, 0);
@ -540,7 +551,7 @@ int RsSshd::recv(uint8_t *buffer, int bytes)
}
int RsSshd::recv(std::string &buffer, int bytes)
int RsSshd::recv(uint32_t chan_id, std::string &buffer, int bytes)
{
char input[bytes];
#if LIBSSH_VERSION_INT >= SSH_VERSION_INT(0,5,0)
@ -556,7 +567,7 @@ int RsSshd::recv(std::string &buffer, int bytes)
}
int RsSshd::recv_blocking(uint8_t *buffer, int bytes)
int RsSshd::recv_blocking(uint32_t chan_id, uint8_t *buffer, int bytes)
{
#if LIBSSH_VERSION_INT >= SSH_VERSION_INT(0,5,0)
int size = ssh_channel_read(mChannel, buffer, bytes, 0);
@ -567,7 +578,7 @@ int RsSshd::recv_blocking(uint8_t *buffer, int bytes)
}
int RsSshd::recv_blocking(std::string &buffer, int bytes)
int RsSshd::recv_blocking(uint32_t chan_id, std::string &buffer, int bytes)
{
char input[bytes];
#if LIBSSH_VERSION_INT >= SSH_VERSION_INT(0,5,0)
@ -582,7 +593,7 @@ int RsSshd::recv_blocking(std::string &buffer, int bytes)
return size;
}
int RsSshd::send(uint8_t *buffer, int bytes)
int RsSshd::send(uint32_t chan_id, uint8_t *buffer, int bytes)
{
#if LIBSSH_VERSION_INT >= SSH_VERSION_INT(0,5,0)
ssh_channel_write(mChannel, buffer, bytes);
@ -592,7 +603,7 @@ int RsSshd::send(uint8_t *buffer, int bytes)
return 1;
}
int RsSshd::send(const std::string &buffer)
int RsSshd::send(uint32_t chan_id, const std::string &buffer)
{
#if LIBSSH_VERSION_INT >= SSH_VERSION_INT(0,5,0)
ssh_channel_write(mChannel, buffer.c_str(), buffer.size());

View file

@ -83,17 +83,18 @@ int adduserpwdhash(std::string username, std::string hash);
// RsComms Interface.
virtual int isOkay();
virtual int error(std::string msg);
virtual int error(uint32_t chan_id, std::string msg);
virtual int recv_ready();
virtual int active_channels(std::list<uint32_t> &chan_ids);
virtual int recv_ready(uint32_t chan_id);
virtual int recv(uint8_t *buffer, int bytes);
virtual int recv(std::string &buffer, int bytes);
virtual int recv_blocking(uint8_t *buffer, int bytes);
virtual int recv_blocking(std::string &buffer, int bytes);
virtual int recv(uint32_t chan_id, uint8_t *buffer, int bytes);
virtual int recv(uint32_t chan_id, std::string &buffer, int bytes);
virtual int recv_blocking(uint32_t chan_id, uint8_t *buffer, int bytes);
virtual int recv_blocking(uint32_t chan_id, std::string &buffer, int bytes);
virtual int send(uint8_t *buffer, int bytes);
virtual int send(const std::string &buffer);
virtual int send(uint32_t chan_id, uint8_t *buffer, int bytes);
virtual int send(uint32_t chan_id, const std::string &buffer);
virtual int setSleepPeriods(float busy, float idle);