mirror of
https://github.com/oxen-io/lokinet.git
synced 2024-10-31 09:20:21 +00:00
baf8019fe5
This commit refactors functionality from the Router class into separate, dedicated classes. There are a few behavior changes that came as a result of discussion on what the correct behavior should be. In addition, many things Router was previously doing can now be provided callback functions to alert the calling point when the asynchronous action completes, successfully or otherwise.
60 lines
1.2 KiB
C++
60 lines
1.2 KiB
C++
#ifndef LLARP_ROUTER_I_OUTBOUND_SESSION_MAKER_HPP
|
|
#define LLARP_ROUTER_I_OUTBOUND_SESSION_MAKER_HPP
|
|
|
|
#include <util/types.hpp>
|
|
|
|
#include <functional>
|
|
|
|
namespace llarp
|
|
{
|
|
namespace util
|
|
{
|
|
struct StatusObject;
|
|
} // namespace util
|
|
|
|
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
|
|
ConnectToRandomRouters(int numDesired, llarp_time_t now) = 0;
|
|
|
|
virtual util::StatusObject
|
|
ExtractStatus() const = 0;
|
|
};
|
|
|
|
} // namespace llarp
|
|
|
|
#endif // LLARP_ROUTER_I_OUTBOUND_SESSION_MAKER_HPP
|