lokinet/llarp/rpc/rpc.hpp

68 lines
1.1 KiB
C++
Raw Normal View History

2018-10-19 11:41:36 +00:00
#ifndef LLARP_RPC_HPP
#define LLARP_RPC_HPP
#include <util/time.hpp>
2018-11-01 12:47:14 +00:00
#include <functional>
#include <memory>
#include <string>
2018-10-19 11:41:36 +00:00
namespace llarp
{
struct PubKey;
struct AbstractRouter;
2018-10-19 11:41:36 +00:00
namespace rpc
{
struct ServerImpl;
2018-11-01 12:47:14 +00:00
/// jsonrpc server
2018-10-19 11:41:36 +00:00
struct Server
{
Server(AbstractRouter* r);
2018-10-19 11:41:36 +00:00
~Server();
bool
Start(const std::string& bindaddr);
/// stop and close
void
Stop();
2018-10-19 11:41:36 +00:00
private:
std::unique_ptr< ServerImpl > m_Impl;
2018-10-19 11:41:36 +00:00
};
2018-11-01 12:47:14 +00:00
struct CallerImpl;
/// jsonrpc caller
struct Caller
{
Caller(AbstractRouter* r);
2018-11-01 12:47:14 +00:00
~Caller();
/// set http basic auth for use with remote rpc endpoint
void
SetBasicAuth(const std::string& user, const std::string& password);
2018-11-01 12:47:14 +00:00
/// start with jsonrpc endpoint address
bool
Start(const std::string& remote);
/// stop and close
void
Stop();
2018-11-21 17:46:33 +00:00
/// do per second tick
2018-11-01 12:47:14 +00:00
void
2018-11-21 17:46:33 +00:00
Tick(llarp_time_t now);
2018-11-01 12:47:14 +00:00
private:
std::unique_ptr< CallerImpl > m_Impl;
2018-11-01 12:47:14 +00:00
};
2018-10-19 11:41:36 +00:00
} // namespace rpc
} // namespace llarp
#endif