2019-06-26 21:39:29 +00:00
|
|
|
#ifndef LLARP_ROUTER_I_OUTBOUND_SESSION_MAKER_HPP
|
|
|
|
#define LLARP_ROUTER_I_OUTBOUND_SESSION_MAKER_HPP
|
|
|
|
|
2019-08-19 09:33:26 +00:00
|
|
|
#include <util/status.hpp>
|
2019-06-26 21:39:29 +00:00
|
|
|
#include <util/types.hpp>
|
|
|
|
|
|
|
|
#include <functional>
|
|
|
|
|
|
|
|
namespace llarp
|
|
|
|
{
|
|
|
|
struct ILinkSession;
|
|
|
|
struct RouterID;
|
|
|
|
struct RouterContact;
|
|
|
|
|
|
|
|
enum class SessionResult
|
|
|
|
{
|
|
|
|
Establish,
|
|
|
|
Timeout,
|
|
|
|
RouterNotFound,
|
|
|
|
InvalidRouter,
|
|
|
|
NoLink
|
|
|
|
};
|
|
|
|
|
|
|
|
using RouterCallback =
|
|
|
|
std::function< void(const RouterID &, const SessionResult) >;
|
|
|
|
|
|
|
|
struct IOutboundSessionMaker
|
|
|
|
{
|
|
|
|
virtual ~IOutboundSessionMaker() = default;
|
|
|
|
|
|
|
|
virtual bool
|
|
|
|
OnSessionEstablished(ILinkSession *session) = 0;
|
|
|
|
|
|
|
|
virtual void
|
|
|
|
OnConnectTimeout(ILinkSession *session) = 0;
|
|
|
|
|
|
|
|
virtual void
|
|
|
|
CreateSessionTo(const RouterID &router, RouterCallback on_result) = 0;
|
|
|
|
|
|
|
|
virtual void
|
|
|
|
CreateSessionTo(const RouterContact &rc, RouterCallback on_result) = 0;
|
|
|
|
|
|
|
|
virtual bool
|
|
|
|
HavePendingSessionTo(const RouterID &router) const = 0;
|
|
|
|
|
|
|
|
virtual void
|
2019-12-09 15:17:02 +00:00
|
|
|
ConnectToRandomRouters(int numDesired) = 0;
|
2019-06-26 21:39:29 +00:00
|
|
|
|
|
|
|
virtual util::StatusObject
|
|
|
|
ExtractStatus() const = 0;
|
2019-08-12 12:40:38 +00:00
|
|
|
|
|
|
|
virtual bool
|
|
|
|
ShouldConnectTo(const RouterID &router) const = 0;
|
2019-06-26 21:39:29 +00:00
|
|
|
};
|
|
|
|
|
|
|
|
} // namespace llarp
|
|
|
|
|
|
|
|
#endif // LLARP_ROUTER_I_OUTBOUND_SESSION_MAKER_HPP
|