Documentation
¶
Overview ¶
Package cdp carries flattened Chrome DevTools sessions over interchangeable transports.
Index ¶
- Constants
- Variables
- func ReadMessage(r *bufio.Reader) ([]byte, error)
- func WithTimeout(ctx context.Context) (context.Context, context.CancelFunc)
- type Conn
- func (c *Conn) Call(ctx context.Context, method string, params any, session string) (json.RawMessage, error)
- func (c *Conn) Close() error
- func (c *Conn) Done() <-chan struct{}
- func (c *Conn) Run(ctx context.Context) error
- func (c *Conn) Send(ctx context.Context, method string, params any, session string) error
- type EventHandler
- type Socket
- type Stream
- type Transport
Constants ¶
const DefaultTimeout = 10 * time.Second
DefaultTimeout bounds commands whose caller has not supplied a deadline.
const MaxMessage = 64 << 20
MaxMessage bounds a single CDP record in bytes.
Variables ¶
var ErrClosed = errors.New("CDP connection closed")
ErrClosed indicates that the transport is no longer available.
Functions ¶
func ReadMessage ¶
ReadMessage accepts only complete NUL-terminated records, with a bound for broken peers.
func WithTimeout ¶
WithTimeout preserves explicit deadlines and bounds otherwise unbounded work.
Types ¶
type Conn ¶
type Conn struct {
// contains filtered or unexported fields
}
Conn multiplexes commands and events on a single transport.
func New ¶
func New(t Transport, handler EventHandler) *Conn
New creates a connection; Run must be started before calling commands.
func (*Conn) Call ¶
func (c *Conn) Call(ctx context.Context, method string, params any, session string) (json.RawMessage, error)
Call waits for a command reply, bounded by the context or DefaultTimeout.
type EventHandler ¶
type EventHandler func(method, session string, params json.RawMessage)
EventHandler runs on the reader goroutine; it must never wait for a CDP reply.
type Socket ¶
type Socket struct {
// contains filtered or unexported fields
}
Socket carries CDP messages over a WebSocket.
type Stream ¶
type Stream struct {
// contains filtered or unexported fields
}
Stream carries complete NUL-delimited records over a bidirectional byte stream.
func NewStream ¶
func NewStream(rw io.ReadWriteCloser) *Stream
NewStream wraps a transport whose Close interrupts blocked reads and writes.