lokinet/include/llarp/link/session.hpp

53 lines
1.3 KiB
C++
Raw Normal View History

#ifndef LLARP_LINK_SESSION_HPP
#define LLARP_LINK_SESSION_HPP
#include <llarp/crypto.hpp>
#include <llarp/net.hpp>
2018-09-06 11:46:19 +00:00
#include <llarp/router_contact.hpp>
#include <functional>
namespace llarp
{
struct LinkIntroMessage;
struct ILinkMessage;
2018-09-04 19:15:06 +00:00
struct ILinkLayer;
struct ILinkSession
{
virtual ~ILinkSession(){};
/// called every event loop tick
2018-09-06 11:46:19 +00:00
std::function< void(void) > Pump;
/// called every timer tick
2018-09-06 11:46:19 +00:00
std::function< void(llarp_time_t) > Tick;
/// send a message buffer to the remote endpoint
2018-09-06 11:46:19 +00:00
std::function< bool(llarp_buffer_t) > SendMessageBuffer;
/// start the connection
2018-09-06 11:46:19 +00:00
std::function< void(void) > Start;
/// send a keepalive to the remote endpoint
2018-09-06 11:46:19 +00:00
std::function< bool(void) > SendKeepAlive;
/// send close message
2018-09-06 11:46:19 +00:00
std::function< void(void) > SendClose;
/// return true if we are established
2018-09-06 11:46:19 +00:00
std::function< bool(void) > IsEstablished;
/// return true if this session has timed out
2018-09-06 11:46:19 +00:00
std::function< bool(llarp_time_t) > TimedOut;
/// get remote public identity key
2018-09-07 17:41:49 +00:00
std::function< const PubKey &(void) > GetPubKey;
/// get remote address
std::function< const Addr &(void) > GetRemoteEndpoint;
/// handle a valid LIM
std::function< bool(const LinkIntroMessage *msg) > GotLIM;
};
} // namespace llarp
#endif