36 lines
771 B
C++
36 lines
771 B
C++
#pragma once
|
|
|
|
#include <functional>
|
|
#include <memory>
|
|
#include <string>
|
|
|
|
namespace sc {
|
|
|
|
struct DiscoveredPeer {
|
|
std::string service_name;
|
|
std::string host;
|
|
uint16_t signaling_port = 0;
|
|
};
|
|
|
|
class DiscoveryService {
|
|
public:
|
|
using PeerCallback = std::function<void ( const DiscoveredPeer & )>;
|
|
|
|
virtual ~DiscoveryService () = default;
|
|
|
|
// Announce this peer on the LAN.
|
|
virtual bool announce ( const std::string &service_name, uint16_t signaling_port ) = 0;
|
|
|
|
// Browse for peers; callback is invoked for each newly found service.
|
|
virtual bool browse ( PeerCallback on_peer ) = 0;
|
|
|
|
virtual void stop () = 0;
|
|
};
|
|
|
|
class DiscoveryFactory {
|
|
public:
|
|
static std::unique_ptr<DiscoveryService> create_avahi ();
|
|
};
|
|
|
|
} // namespace sc
|