Struct iroh_relay::client::Client
source · pub struct Client { /* private fields */ }Expand description
An HTTP Relay client.
Cheaply clonable.
Implementations§
source§impl Client
impl Client
sourcepub fn public_key(&self) -> PublicKey
pub fn public_key(&self) -> PublicKey
The public key for this client
sourcepub async fn connect(&self) -> Result<Conn, ClientError>
pub async fn connect(&self) -> Result<Conn, ClientError>
Connects to a relay Server and returns the underlying relay connection.
Returns ClientError::Closed if the Client is closed.
If there is already an active relay connection, returns the already
connected crate::RelayConn.
sourcepub async fn note_preferred(&self, is_preferred: bool)
pub async fn note_preferred(&self, is_preferred: bool)
Let the server know that this client is the preferred client
sourcepub async fn local_addr(&self) -> Option<SocketAddr>
pub async fn local_addr(&self) -> Option<SocketAddr>
Get the local addr of the connection. If there is no current underlying relay connection
or the Client is closed, returns None.
sourcepub async fn ping(&self) -> Result<Duration, ClientError>
pub async fn ping(&self) -> Result<Duration, ClientError>
Send a ping to the server. Return once we get an expected pong.
There must be a task polling recv_detail to process the pong response.
sourcepub async fn send_pong(&self, data: [u8; 8]) -> Result<(), ClientError>
pub async fn send_pong(&self, data: [u8; 8]) -> Result<(), ClientError>
Send a pong back to the server.
If there is no underlying active relay connection, it creates one before attempting to send the pong message.
If there is an error sending pong, it closes the underlying relay connection before returning.
sourcepub async fn send(
&self,
dst_key: PublicKey,
b: Bytes
) -> Result<(), ClientError>
pub async fn send( &self, dst_key: PublicKey, b: Bytes ) -> Result<(), ClientError>
Send a packet to the server.
If there is no underlying active relay connection, it creates one before attempting to send the message.
If there is an error sending the packet, it closes the underlying relay connection before returning.
sourcepub async fn close(self) -> Result<(), ClientError>
pub async fn close(self) -> Result<(), ClientError>
Close the http relay connection.
sourcepub async fn close_for_reconnect(&self) -> Result<(), ClientError>
pub async fn close_for_reconnect(&self) -> Result<(), ClientError>
Disconnect the http relay connection.
sourcepub async fn is_connected(&self) -> Result<bool, ClientError>
pub async fn is_connected(&self) -> Result<bool, ClientError>
Returns true if the underlying relay connection is established.