14#include "librats/util/rats_export.h"
20#include "librats/core/types.h"
53 virtual const std::string&
protocol()
const = 0;
66 virtual std::vector<PeerInfo>
peers()
const = 0;
A dialable transport endpoint: a numeric IP + port.
Lightweight byte container aliases and a non-owning byte view.
Non-owning view over a contiguous run of bytes.
virtual bool broadcast(MessageType type, ByteView payload)=0
Send to every connected peer.
virtual void on(MessageType type, MessageHandler handler)=0
std::function< void(const Address &)> DialFailedHandler
virtual const std::string & protocol() const =0
app protocol id (e.g. "librats/1.0"); namespaces discovery
virtual const PeerId & local_id() const =0
virtual void connect(const Address &address)=0
dial a discovered peer
virtual uint8_t transports() const
Which transports that port actually accepts, as a PeerTransports bitmask — the same value identify re...
std::function< void(const PeerId &, CloseReason)> PeerDisconnectHandler
A peer went away, and why.
std::function< void(const Peer &, ByteView)> MessageHandler
virtual bool send(const PeerId &to, MessageType type, ByteView payload)=0
Send to one peer.
virtual void on_peer_disconnected(PeerDisconnectHandler handler)=0
virtual ~PeerNetwork()=default
virtual void on_peer_connected(PeerEventHandler handler)=0
virtual bool peer_writable(const PeerId &) const
The same question send() answers — "has this peer room for more?" — asked without sending anything.
virtual void on_dial_failed(DialFailedHandler handler)=0
virtual std::vector< PeerInfo > peers() const =0
snapshot incl. dialable addresses
virtual uint16_t listen_port() const =0
our advertised listen port (shared by both transports)
virtual void on_peer_writable(PeerEventHandler)
A peer whose send queue had filled up has drained back under its mark, so sending to it may resume.
std::function< void(const Peer &)> PeerEventHandler
virtual std::vector< PeerId > connected_peers() const =0
A pluggable network subsystem.
virtual ~Subsystem()=default
virtual void attach(NodeContext &ctx)=0
Two-level wire framing: outer length-prefixed blocks, inner messages.
MessageType
Inner-message kind. Application traffic uses App, addressed by channel.
Self-certifying peer identity.
Addressing/metadata for a peer — the shareable, persistable identity.