pub struct ServerClient { /* private fields */ }Expand description
A live connection to the server. Cloneable handle; cloning shares the same underlying socket.
Implementations§
Source§impl ServerClient
impl ServerClient
Sourcepub async fn connect(
url: &str,
dial: &DialMode,
identity: Arc<Identity>,
rooms: Vec<String>,
) -> Result<(Self, UnboundedReceiver<ServerEvent>)>
pub async fn connect( url: &str, dial: &DialMode, identity: Arc<Identity>, rooms: Vec<String>, ) -> Result<(Self, UnboundedReceiver<ServerEvent>)>
Open a connection, send the initial hello, and return the client
plus a stream of ServerEvents.
url:ws://<onion>:80/ws(onion),wss://relay/ws(clearnet TLS), orws://host:port/ws(clearnet plain / tests).dial: how to physically reach it — one of the transport “doors” (Socks5for onion via Tor,Tlsforwss://,Directforws://).identity: our identity, used to answer the relay’s authChallenge(huddle 1.1.4). The connector signs the challenge nonce and sends the pubkey + signature inHello; the relay rejects us otherwise.
Sourcepub fn publish(&self, room: &str, id: &str, payload: &[u8]) -> Result<()>
pub fn publish(&self, room: &str, id: &str, payload: &[u8]) -> Result<()>
Send a room’s opaque wire bytes to the server for fan-out.
Sourcepub fn send_direct(
&self,
to: &str,
room: &str,
id: &str,
payload: &[u8],
) -> Result<()>
pub fn send_direct( &self, to: &str, room: &str, id: &str, payload: &[u8], ) -> Result<()>
huddle 1.2: deliver payload straight to recipient to’s
fingerprint, independent of room membership (1:1 DMs, friend requests).
The server delivers it live to every connection to has open, or
queues it in their mailbox when they’re offline. room is the opaque
tag the recipient files it under.
Sourcepub fn subscribe(&self, room: &str) -> Result<()>
pub fn subscribe(&self, room: &str) -> Result<()>
Assert membership of a room so the server mailboxes us when offline.
pub fn unsubscribe(&self, room: &str) -> Result<()>
Sourcepub fn create_connect_token(&self) -> Result<()>
pub fn create_connect_token(&self) -> Result<()>
huddle 1.2.1: ask the relay to mint a short-lived connect code bound to
our identity. The reply arrives as ServerEvent::ConnectToken.
Sourcepub fn redeem_connect_token(&self, token: &str) -> Result<()>
pub fn redeem_connect_token(&self, token: &str) -> Result<()>
huddle 1.2.1: ask the relay to resolve a connect code to its owner.
The reply arrives as ServerEvent::ConnectTokenResolved.
pub fn ping(&self) -> Result<()>
Trait Implementations§
Source§impl Clone for ServerClient
impl Clone for ServerClient
Source§fn clone(&self) -> ServerClient
fn clone(&self) -> ServerClient
1.0.0 (const: unstable) · Source§fn clone_from(&mut self, source: &Self)
fn clone_from(&mut self, source: &Self)
source. Read moreAuto Trait Implementations§
impl Freeze for ServerClient
impl RefUnwindSafe for ServerClient
impl Send for ServerClient
impl Sync for ServerClient
impl Unpin for ServerClient
impl UnsafeUnpin for ServerClient
impl UnwindSafe for ServerClient
Blanket Implementations§
Source§impl<T> BorrowMut<T> for Twhere
T: ?Sized,
impl<T> BorrowMut<T> for Twhere
T: ?Sized,
Source§fn borrow_mut(&mut self) -> &mut T
fn borrow_mut(&mut self) -> &mut T
Source§impl<T> CloneToUninit for Twhere
T: Clone,
impl<T> CloneToUninit for Twhere
T: Clone,
Source§impl<T> Instrument for T
impl<T> Instrument for T
Source§fn instrument(self, span: Span) -> Instrumented<Self>
fn instrument(self, span: Span) -> Instrumented<Self>
Source§fn in_current_span(self) -> Instrumented<Self>
fn in_current_span(self) -> Instrumented<Self>
Source§impl<T> IntoEither for T
impl<T> IntoEither for T
Source§fn into_either(self, into_left: bool) -> Either<Self, Self>
fn into_either(self, into_left: bool) -> Either<Self, Self>
self into a Left variant of Either<Self, Self>
if into_left is true.
Converts self into a Right variant of Either<Self, Self>
otherwise. Read moreSource§fn into_either_with<F>(self, into_left: F) -> Either<Self, Self>
fn into_either_with<F>(self, into_left: F) -> Either<Self, Self>
self into a Left variant of Either<Self, Self>
if into_left(&self) returns true.
Converts self into a Right variant of Either<Self, Self>
otherwise. Read more