pub struct Endpoint { /* private fields */ }connect-server only.Expand description
Everything the routes need.
Cloneable and cheap: an Arc of each service.
Implementations§
Source§impl Endpoint
impl Endpoint
Sourcepub const MAX_WAITING_NODES: usize = LongPoll::MAX_WAITING
pub const MAX_WAITING_NODES: usize = LongPoll::MAX_WAITING
The most long-polling nodes one endpoint will remember.
waitForPairing carries no bearer and its body is a list of identifiers the caller
chose, so the table it fills is bounded. A LAN endpoint talks to tens of devices.
Sourcepub const MAX_NODES_PER_POLL: usize = LongPoll::MAX_PER_POLL
pub const MAX_NODES_PER_POLL: usize = LongPoll::MAX_PER_POLL
The most nodes a single waitForPairing may ask about.
Sourcepub fn new(pairing: Arc<PairingService>, session: Arc<SessionService>) -> Self
pub fn new(pairing: Arc<PairingService>, session: Arc<SessionService>) -> Self
An endpoint serving both APIs.
Sourcepub const fn with_max_message_bytes(self, bytes: usize) -> Self
pub const fn with_max_message_bytes(self, bytes: usize) -> Self
Buffer no WebSocket frame larger than this.
Defaults to
DecodeOptions::DEFAULT_MAX_BYTES,
the mebibyte the codec and the session engines already use. Raise it only together
with the session’s own max_message_bytes: a frame larger than the codec will
parse is a frame that is buffered and then refused.
Sourcepub const fn max_message_bytes(&self) -> usize
pub const fn max_message_bytes(&self) -> usize
The largest WebSocket frame this endpoint will buffer.
Sourcepub fn on_prepare_pairing(
self,
handler: impl Fn(PrepareSignal) + Send + Sync + 'static,
) -> Self
pub fn on_prepare_pairing( self, handler: impl Fn(PrepareSignal) + Send + Sync + 'static, ) -> Self
React to a client announcing that its user has started pairing.
Typically: show the pairing code on a display, or light an LED. The handler runs
inside the request, so it must not block — and it must not be trusted, because the
signal is unauthenticated and only reaches you at all through the same-subnet
check in lan_router.
Sourcepub fn with_clock(self, clock: fn() -> Timestamp) -> Self
pub fn with_clock(self, clock: fn() -> Timestamp) -> Self
Use a different clock — a virtual one, in a test.
Sourcepub fn session(&self) -> &Arc<SessionService> ⓘ
pub fn session(&self) -> &Arc<SessionService> ⓘ
The session service, for a host that also terminates the WebSocket.
Sourcepub fn instruct_waiting_node(&self, client: NodeId, action: WaitAction)
pub fn instruct_waiting_node(&self, client: NodeId, action: WaitAction)
Tell a long-polling node to do something the next time it asks.
This is the other half of lan_router’s waitForPairing: a Resource Manager
with no listening socket cannot be dialled, so when a person presses the pairing
button here the instruction waits until that node next checks in. A request that
is already held open is woken at once, so “waits” is usually microseconds.
Sourcepub fn waiting_nodes(&self) -> Vec<(NodeId, WaitingNode)>
pub fn waiting_nodes(&self) -> Vec<(NodeId, WaitingNode)>
Every node that is long-polling this endpoint, and what it has said about itself.
What a user interface lists when somebody asks “what is out there to pair with?” —
the counterpart of GET /v1/nodes for clients that have no server to browse.
Sourcepub fn live_attempts(&self) -> usize
pub fn live_attempts(&self) -> usize
How many attempts the router is tracking. For a test, and for a health endpoint.