pub struct WebSocketRegistry { /* private fields */ }Expand description
A registry that captures WebSocket connections from a page session.
Subscribes to the session’s event stream (before Network is expected to
emit, though the page session already has Network enabled) and routes each
Network.webSocket* event to the matching WebSocket, keyed by
requestId. The page can later iterate all or look one up by
id when wiring its on('websocket') handler.
Cheaply cloneable; clones share the same capture state.
Implementations§
Source§impl WebSocketRegistry
impl WebSocketRegistry
Sourcepub fn attach(&self, session: &Arc<CdpSession>)
pub fn attach(&self, session: &Arc<CdpSession>)
Begin capturing WebSocket events from session. Subscribes to the
session event stream and spawns a dispatcher task that partitions
Network.webSocket* events by requestId. Returns immediately; capture
continues for the life of the spawned task.
Subscribe-first is honoured: the subscription is taken before any
further Network interaction so no events are missed.
Sourcepub async fn get(&self, request_id: &str) -> Option<WebSocket>
pub async fn get(&self, request_id: &str) -> Option<WebSocket>
Look up a captured connection by requestId.
Sourcepub fn on_created(&self) -> Receiver<WebSocket>
pub fn on_created(&self) -> Receiver<WebSocket>
Subscribe to newly-created connections (one event per
webSocketCreated).
Trait Implementations§
Source§impl Clone for WebSocketRegistry
impl Clone for WebSocketRegistry
Source§fn clone(&self) -> WebSocketRegistry
fn clone(&self) -> WebSocketRegistry
1.0.0 (const: unstable) · Source§fn clone_from(&mut self, source: &Self)
fn clone_from(&mut self, source: &Self)
source. Read more