Skip to main content

Module web_socket

Module web_socket 

Source
Expand description

WebSocket — a captured WebSocket connection, reconstructed from CDP Network.webSocket* events.

CDP does not expose a live WebSocket object; instead the Network domain emits a lifecycle of events for each connection, keyed by requestId:

  • Network.webSocketCreated — the URL (and optional request).
  • Network.webSocketWillSendHandshakeRequest — outgoing request headers.
  • Network.webSocketHandshakeResponseReceived — status code + response headers.
  • Network.webSocketFrameSent — a frame the page sent.
  • Network.webSocketFrameReceived — a frame the page received.
  • Network.webSocketFrameError — a protocol error.
  • Network.webSocketClosed — the connection closed (with a timestamp).

WebSocketRegistry subscribes to the page session, partitions events by requestId, and accumulates them into one WebSocket per connection. The page-side page.on('websocket') wiring (and the WebSocket::new the page would hand callers) arrives in a later wave — this module provides the type and the capture/registry logic only.

The accumulated WebSocket is cheaply cloneable (Arc<Inner>); clones share the same live state, so frames arriving after the handle is handed out are visible via frames and the on_* handlers.

Structs§

WebSocket
A captured WebSocket connection.
WebSocketCloseInfo
Information about a closed WebSocket connection.
WebSocketFrame
A single WebSocket frame payload, tagged with its direction.
WebSocketHandshake
The WebSocket handshake result.
WebSocketRegistry
A registry that captures WebSocket connections from a page session.

Enums§

FrameData
A frame’s payload, distinguishing text from binary.
FrameDirection
Direction of a WebSocketFrame.
WaitError
Errors from WebSocket::wait_for_event.
WebSocketLiveEvent
A live event emitted on a WebSocket’s broadcast bus.