pub struct RelayHub { /* private fields */ }Expand description
A Hub with no listener of its own — for embedding inside ANOTHER server’s accept loop
(largo serve’s /_relay upgrade, registered on logicaffeine_system::http::server’s
shared loop, or a compiled full-stack binary’s own Serve). serve is bind-a-listener plus
exactly this; the pub/sub semantics — subscribe, publish (never echoed to the publisher),
unsubscribe on drop — are the identical Hub either way.
Implementations§
Source§impl RelayHub
impl RelayHub
Sourcepub fn new() -> Self
pub fn new() -> Self
A hub with no bridge to the libp2p mesh — the browser↔browser-via-relay path, the same
pub/sub serve itself runs.
Sourcepub async fn accept(&self, stream: TcpStream, prefix: Vec<u8>)
pub async fn accept(&self, stream: TcpStream, prefix: Vec<u8>)
Take over an ALREADY-UPGRADED stream: the embedding server has already answered the
client’s 101 Switching Protocols off a request it parsed itself — prefix is whatever
bytes it had already read past that request (almost always empty; a client waits for the
101 before framing its first message). Runs the connection’s pub/sub loop until it
closes. Spawns nothing itself — the caller decides whether to await it inline or spawn it,
exactly the choice an embedding accept loop already makes for an ordinary connection.
Sourcepub fn upgrades(&self) -> Vec<(&'static str, UpgradeHandler)>
pub fn upgrades(&self) -> Vec<(&'static str, UpgradeHandler)>
This hub as the upgrade table a server registers: RELAY_PATH, the one path every LOGOS
page dials for Publish, When a message arrives and a shared on store.