Documentation
¶
Overview ¶
Package cdp provides a minimal Chrome DevTools Protocol client.
Index ¶
- Constants
- type Client
- func (c *Client) Close() error
- func (c *Client) Err() error
- func (c *Client) Send(method string, params interface{}) (json.RawMessage, error)
- func (c *Client) SendContext(ctx context.Context, method string, params interface{}) (json.RawMessage, error)
- func (c *Client) SendToSession(ctx context.Context, sessionID string, method string, params interface{}) (json.RawMessage, error)
- func (c *Client) Subscribe(method string, handler func(Event))
- type Conn
- type Error
- type Event
- type Request
- type Response
Constants ¶
View Source
const DefaultTimeout = 60 * time.Second
DefaultTimeout is the default timeout for CDP commands.
Variables ¶
This section is empty.
Functions ¶
This section is empty.
Types ¶
type Client ¶
type Client struct {
// contains filtered or unexported fields
}
Client is a CDP protocol client.
func (*Client) Send ¶
func (c *Client) Send(method string, params interface{}) (json.RawMessage, error)
Send sends a CDP command and waits for the response. Uses the default timeout.
func (*Client) SendContext ¶
func (c *Client) SendContext(ctx context.Context, method string, params interface{}) (json.RawMessage, error)
SendContext sends a CDP command with a context for cancellation.
func (*Client) SendToSession ¶
func (c *Client) SendToSession(ctx context.Context, sessionID string, method string, params interface{}) (json.RawMessage, error)
SendToSession sends a CDP command to a specific session. If sessionID is empty, the command is sent to the browser-level target.
type Conn ¶
type Conn interface {
// Read reads a message from the connection.
// Returns message type, payload, and any error.
Read(ctx context.Context) (websocket.MessageType, []byte, error)
// Write writes a message to the connection.
Write(ctx context.Context, typ websocket.MessageType, p []byte) error
// Close closes the connection with a status code and reason.
Close(code websocket.StatusCode, reason string) error
}
Conn defines the interface for a WebSocket connection. This abstraction enables testing with mock connections.
type Error ¶
type Error struct {
Code int `json:"code"`
Message string `json:"message"`
Data string `json:"data,omitempty"`
}
Error represents a CDP protocol error.
type Event ¶
type Event struct {
Method string `json:"method"`
Params json.RawMessage `json:"params"`
SessionID string `json:"sessionId,omitempty"`
}
Event represents a CDP event notification.
Click to show internal directories.
Click to hide internal directories.