My Project 2.4.4
C++ Distributed Hash Table
Loading...
Searching...
No Matches
Public Types | Public Member Functions | Static Public Attributes | List of all members
dht::PeerDiscovery Class Reference

Public Types

using ServiceDiscoveredCallback = std::function< void(msgpack::object &&, SockAddr &&)>
 

Public Member Functions

 PeerDiscovery (in_port_t port=DEFAULT_PORT, std::shared_ptr< asio::io_context > ioContext={}, std::shared_ptr< Logger > logger={})
 
void startDiscovery (const std::string &type, ServiceDiscoveredCallback callback)
 
template<typename T >
void startDiscovery (const std::string &type, std::function< void(T &&, SockAddr &&)> cb)
 
void startPublish (const std::string &type, const msgpack::sbuffer &pack_buf)
 
void startPublish (sa_family_t domain, const std::string &type, const msgpack::sbuffer &pack_buf)
 
template<typename T >
void startPublish (const std::string &type, const T &object)
 
void stop ()
 
bool stopDiscovery (const std::string &type)
 
bool stopPublish (const std::string &type)
 
bool stopPublish (sa_family_t domain, const std::string &type)
 
void connectivityChanged ()
 

Static Public Attributes

static constexpr in_port_t DEFAULT_PORT = 8888
 

Detailed Description

Definition at line 35 of file peer_discovery.h.

Member Typedef Documentation

◆ ServiceDiscoveredCallback

using dht::PeerDiscovery::ServiceDiscoveredCallback = std::function<void(msgpack::object&&, SockAddr&&)>

Definition at line 39 of file peer_discovery.h.

Member Function Documentation

◆ startDiscovery() [1/2]

void dht::PeerDiscovery::startDiscovery ( const std::string &  type,
ServiceDiscoveredCallback  callback 
)

startDiscovery - Keep Listening data from the sender until node is joinned or stop is called

◆ startDiscovery() [2/2]

template<typename T >
void dht::PeerDiscovery::startDiscovery ( const std::string &  type,
std::function< void(T &&, SockAddr &&)>  cb 
)
inline

Definition at line 50 of file peer_discovery.h.

◆ startPublish() [1/2]

void dht::PeerDiscovery::startPublish ( const std::string &  type,
const msgpack::sbuffer &  pack_buf 
)

startPublish - Keeping sending data until node is joinned or stop is called

◆ startPublish() [2/2]

template<typename T >
void dht::PeerDiscovery::startPublish ( const std::string &  type,
const T &  object 
)
inline

Definition at line 63 of file peer_discovery.h.

◆ stop()

void dht::PeerDiscovery::stop ( )

Thread Stopper

◆ stopDiscovery()

bool dht::PeerDiscovery::stopDiscovery ( const std::string &  type)

Remove possible callBack to discovery

◆ stopPublish()

bool dht::PeerDiscovery::stopPublish ( const std::string &  type)

Remove different serivce message to send

Member Data Documentation

◆ DEFAULT_PORT

constexpr in_port_t dht::PeerDiscovery::DEFAULT_PORT = 8888
staticconstexpr

Definition at line 38 of file peer_discovery.h.


The documentation for this class was generated from the following file: