lokinet/llarp/rpc/rpc.hpp

69 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>
2020-05-06 20:38:44 +00:00
#include <net/ip_address.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
2020-05-06 20:38:44 +00:00
Start(const IpAddress& bindaddr);
2018-10-19 11:41:36 +00:00
/// 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
SetAuth(const std::string& user, const std::string& password);
2018-11-01 12:47:14 +00:00
/// start with jsonrpc endpoint address
bool
2020-05-06 20:38:44 +00:00
Start(const IpAddress& remote);
2018-11-01 12:47:14 +00:00
/// 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