2012-08-20 10:59:41 -04:00
|
|
|
/*
|
|
|
|
* 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 RPC_MEDIATOR_H
|
|
|
|
#define RPC_MEDIATOR_H
|
|
|
|
|
|
|
|
/*
|
|
|
|
* Interface between RpcServer and RpcComms.
|
|
|
|
*/
|
|
|
|
|
|
|
|
#include <string>
|
|
|
|
#include <inttypes.h>
|
|
|
|
|
|
|
|
#include "rpcsystem.h"
|
|
|
|
|
|
|
|
class RpcServer;
|
|
|
|
|
|
|
|
class RpcMediator: public RpcSystem
|
|
|
|
{
|
|
|
|
public:
|
|
|
|
|
|
|
|
RpcMediator(RpcComms *c);
|
|
|
|
void setRpcServer(RpcServer *s) { mServer = s; } /* Must only be called during setup */
|
|
|
|
|
|
|
|
// Overloaded from RpcSystem.
|
2012-09-01 15:35:23 -04:00
|
|
|
virtual void reset(uint32_t chan_id);
|
2012-08-20 10:59:41 -04:00
|
|
|
virtual int tick();
|
|
|
|
|
|
|
|
int recv();
|
2012-09-01 15:35:23 -04:00
|
|
|
int recv_msg(uint32_t chan_id);
|
|
|
|
int send(uint32_t chan_id, uint32_t msg_id, uint32_t req_id, const std::string &msg);
|
2012-08-20 10:59:41 -04:00
|
|
|
|
2012-09-09 07:48:25 -04:00
|
|
|
int error(uint32_t chan_id, std::string msg); // pass an error up to comms level.
|
2012-08-20 10:59:41 -04:00
|
|
|
private:
|
|
|
|
RpcComms *mComms;
|
|
|
|
RpcServer *mServer;
|
|
|
|
|
|
|
|
};
|
|
|
|
|
|
|
|
|
|
|
|
/* Msg Packing */
|
|
|
|
class MsgPacker
|
|
|
|
{
|
|
|
|
public:
|
|
|
|
static int headersize();
|
|
|
|
static bool serialiseHeader(uint32_t msg_id, uint32_t req_id, uint32_t msg_size, uint8_t *buffer, uint32_t bufsize);
|
|
|
|
static bool deserialiseHeader(uint32_t &msg_id, uint32_t &req_id, uint32_t &msg_size, uint8_t *buffer, uint32_t bufsize);
|
|
|
|
};
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
#endif /* RPC_MEDIATOR_H */
|