mirror of
https://github.com/RetroShare/RetroShare.git
synced 2025-05-19 06:20:44 -04:00
Added first version of RPC system for external control of retroshare-nogui.
The protocol message format is as follows: [HEADER: 16 bytes: 4 x Network Order uint32_t][ VARIABLE LENGTH BODY ] [ MAGIC_CODE ] [ MSG_ID ] [ REQ_ID ] [ BODY_SIZE ] [ ........ BODY ......... ] MagicCode = 0x137f0001 ... this will be incremented for new versions of the protocol. MsgID = Corresponds to the format of the Body. ReqID = Generated by Requester, Returned in Response, make sure its unique. (undefined behaviour for duplicates) BodySize = Byte Length of Body. The Body will consist of a protobuf encoded message. For the moment, the RPC server just ECHOs the request back to the sender - for testing purposes. Usage: * Create SSH connection to retroshare-nogui. * Create Request Message(s), and send over SSH channel - You can send as meny requests as you want. * They will processed, and responses sent back (potentially in an arbitary order). Specific Changes here: * Modified rssshd to support arbitary recv/send applications. (interface is RpcComms). * Added rpc directory, with server, setup and echo service. * Modified Menu System to use the new interface to rssshd * Wrote new matching interface for Terminal Usage. - NOTE: Strange BUG in Terminal version.... causes stderr to disappear. TODO. * Added -C commandline option to switch on RPC system. This is the first version - so I expect there will be bugs. Please report for a prompt fix! git-svn-id: http://svn.code.sf.net/p/retroshare/code/branches/v0.5-gxs-b1@5444 b45a01b8-16f6-495d-af2f-9b41ad6348cc
This commit is contained in:
parent
c17460d1b1
commit
bb10b6b400
20 changed files with 1612 additions and 72 deletions
61
retroshare-nogui/src/rpcsystem.h
Normal file
61
retroshare-nogui/src/rpcsystem.h
Normal file
|
@ -0,0 +1,61 @@
|
|||
/*
|
||||
* RetroShare External Interface.
|
||||
*
|
||||
* Copyright 2012-2012 by Robert Fernie.
|
||||
*
|
||||
* This library is free software; you can redistribute it and/or
|
||||
* modify it under the terms of the GNU Library General Public
|
||||
* License Version 2.1 as published by the Free Software Foundation.
|
||||
*
|
||||
* This library is distributed in the hope that it will be useful,
|
||||
* but WITHOUT ANY WARRANTY; without even the implied warranty of
|
||||
* MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the GNU
|
||||
* Library General Public License for more details.
|
||||
*
|
||||
* You should have received a copy of the GNU Library General Public
|
||||
* License along with this library; if not, write to the Free Software
|
||||
* Foundation, Inc., 59 Temple Place, Suite 330, Boston, MA 02111-1307
|
||||
* USA.
|
||||
*
|
||||
* Please report all bugs and problems to "retroshare@lunamutt.com".
|
||||
*
|
||||
*/
|
||||
|
||||
|
||||
#ifndef RS_RPC_SYSTEM_H
|
||||
#define RS_RPC_SYSTEM_H
|
||||
|
||||
#include <string>
|
||||
#include <inttypes.h>
|
||||
|
||||
class RpcComms
|
||||
{
|
||||
public:
|
||||
virtual int isOkay() = 0;
|
||||
virtual int error(std::string msg) = 0;
|
||||
|
||||
virtual int recv_ready() = 0;
|
||||
virtual int recv(uint8_t *buffer, int bytes) = 0;
|
||||
virtual int recv(std::string &buffer, int bytes) = 0;
|
||||
|
||||
// these make it easier...
|
||||
virtual int recv_blocking(uint8_t *buffer, int bytes) = 0;
|
||||
virtual int recv_blocking(std::string &buffer, int bytes) = 0;
|
||||
|
||||
virtual int send(uint8_t *buffer, int bytes) = 0;
|
||||
virtual int send(const std::string &buffer) = 0;
|
||||
|
||||
virtual int setSleepPeriods(float /* busy */, float /* idle */) { return 0; }
|
||||
};
|
||||
|
||||
|
||||
class RpcSystem
|
||||
{
|
||||
public:
|
||||
/* this must be regularly ticked to update the display */
|
||||
virtual void reset() = 0;
|
||||
virtual int tick() = 0;
|
||||
};
|
||||
|
||||
|
||||
#endif // RS_RPC_SERVER_H
|
Loading…
Add table
Add a link
Reference in a new issue