pub struct Endpoint { /* private fields */ }Expand description
Tx5 endpoint.
Implementations§
Source§impl Endpoint
impl Endpoint
Sourcepub fn new(config: Arc<Config>) -> (Self, EndpointRecv)
pub fn new(config: Arc<Config>) -> (Self, EndpointRecv)
Construct a new tx5 endpoint.
Sourcepub async fn listen(&self, sig_url: SigUrl) -> Option<PeerUrl>
pub async fn listen(&self, sig_url: SigUrl) -> Option<PeerUrl>
Connect to a signal server as a listener, allowing incoming connections. You probably only want to call this once.
Sourcepub fn close(&self, peer_url: &PeerUrl)
pub fn close(&self, peer_url: &PeerUrl)
Request that the peer connection identified by the given peer_url
is closed.
Sourcepub async fn send(&self, peer_url: PeerUrl, data: Vec<u8>) -> Result<()>
pub async fn send(&self, peer_url: PeerUrl, data: Vec<u8>) -> Result<()>
Send data to a remote on this tx5 endpoint.
The future returned from this method will resolve when the data is handed off to the networking backend or the connection attempt to the peer has failed.
Sourcepub async fn broadcast(&self, data: &[u8])
pub async fn broadcast(&self, data: &[u8])
Broadcast data to all connections that happen to be open.
If no connections are open, no data will be broadcast. The future returned from this method will resolve when all broadcast messages have been handed off to our networking backend (or have timed out).
Sourcepub fn get_listening_addresses(&self) -> Vec<PeerUrl>
pub fn get_listening_addresses(&self) -> Vec<PeerUrl>
Get a list of listening addresses (PeerUrls) at which this endpoint is currently reachable.
Sourcepub fn get_connected_peer_addresses(&self) -> Vec<PeerUrl>
pub fn get_connected_peer_addresses(&self) -> Vec<PeerUrl>
Get the list of peers (PeerUrls) that this endpoint is currently connected to.