pub struct Server { /* private fields */ }Expand description
Server for accepting MoQ connections.
Accepts QUIC (and optionally WebSocket), plus plaintext qmux over TCP
(--server-tcp-bind) and Unix sockets (--server-unix-bind). Create via
ServerConfig::init or Server::new.
Implementations§
Source§impl Server
impl Server
pub fn new(config: ServerConfig) -> Result<Self>
Sourcepub fn with_websocket(self, websocket: Option<Listener>) -> Self
pub fn with_websocket(self, websocket: Option<Listener>) -> Self
Add a standalone WebSocket listener on a separate TCP port.
This is useful for simple applications that want WebSocket on a dedicated port.
For applications that need WebSocket on the same HTTP port (e.g. moq-relay),
use qmux::Session::accept() with your own HTTP framework instead.
pub fn with_publish(self, publish: impl Into<Option<OriginConsumer>>) -> Self
pub fn with_consume(self, consume: impl Into<Option<OriginProducer>>) -> Self
Sourcepub fn with_stats(self, stats: StatsHandle) -> Self
pub fn with_stats(self, stats: StatsHandle) -> Self
Attach a tier-scoped moq_net::StatsHandle to all sessions accepted by this server.
Sourcepub async fn serve_publish(self, origin: OriginConsumer) -> Result<()>
pub async fn serve_publish(self, origin: OriginConsumer) -> Result<()>
Accept sessions until the listener stops, serving origin to each subscriber.
Spawns a task per session and logs (rather than propagates) per-session
errors, so one bad peer never tears down the listener. Returns when
interrupted (Ctrl-C) or on a fatal bind failure. For per-session auth or
routing, drive accept yourself instead.
Sourcepub async fn serve_consume(self, origin: OriginProducer) -> Result<()>
pub async fn serve_consume(self, origin: OriginProducer) -> Result<()>
Accept sessions until the listener stops, ingesting each publisher into origin.
The mirror of serve_publish for the consume direction.
pub fn tls_info(&self) -> Arc<RwLock<Info>> ⓘ
Sourcepub async fn accept(&mut self) -> Option<Request>
pub async fn accept(&mut self) -> Option<Request>
Returns the next partially established session, across every configured transport (QUIC, WebSocket, and plaintext qmux over TCP/Unix).
This returns a Request instead of a session so the connection can be rejected early on an invalid path or missing auth. Call Request::ok or Request::close to complete the handshake.