pub struct WebSocket { /* private fields */ }Expand description
A captured WebSocket connection.
State is shared across clones (via Arc<Inner>); frames and close info
accumulate as CDP events arrive on the registry’s subscription.
Implementations§
Source§impl WebSocket
impl WebSocket
Sourcepub fn request_id(&self) -> &str
pub fn request_id(&self) -> &str
The CDP requestId identifying this connection.
Sourcepub fn handshake(&self) -> WebSocketHandshake
pub fn handshake(&self) -> WebSocketHandshake
A snapshot of the handshake (request + response headers, status).
Sourcepub fn frames(&self) -> Vec<WebSocketFrame>
pub fn frames(&self) -> Vec<WebSocketFrame>
A snapshot of all accumulated frames, in arrival order.
Sourcepub fn error(&self) -> Option<String>
pub fn error(&self) -> Option<String>
The protocol error reported by webSocketFrameError, if any.
Sourcepub fn close_info(&self) -> Option<WebSocketCloseInfo>
pub fn close_info(&self) -> Option<WebSocketCloseInfo>
Close info, once the connection has closed. None until
webSocketClosed arrives.
Sourcepub fn on_frame<F, Fut>(&self, handler: F)
pub fn on_frame<F, Fut>(&self, handler: F)
Register a handler invoked for every frame (sent or received) on this connection, mirroring Playwright’s per-connection event surface.
Sourcepub fn on_frame_received<F, Fut>(&self, handler: F)
pub fn on_frame_received<F, Fut>(&self, handler: F)
Register a handler invoked for every frame the page receives.
Sourcepub fn on_frame_sent<F, Fut>(&self, handler: F)
pub fn on_frame_sent<F, Fut>(&self, handler: F)
Register a handler invoked for every frame the page sends.
Sourcepub fn on_close<F, Fut>(&self, handler: F)
pub fn on_close<F, Fut>(&self, handler: F)
Register a handler invoked when the connection closes.
Sourcepub async fn wait_for_event(
&self,
timeout: Duration,
) -> Result<WebSocketLiveEvent, WaitError>
pub async fn wait_for_event( &self, timeout: Duration, ) -> Result<WebSocketLiveEvent, WaitError>
Wait for the next live event of any kind, or time out after timeout.
This consumes from a fresh subscription, so it observes only events that
arrive after the call (it is not a replay of accumulated state — use
frames/close_info for history).