Documentation ¶
Overview ¶
Package session implements a session Manager for establishing session connections to targets (via the Target domain). Session connections allow a single websocket connection (from the provided cdp.Client) to be used for communicating with multiple targets.
Initialize a new session Manager.
c := cdp.NewClient(conn) // cdp.Client with websocket connection. m, err := session.NewManager(c) if err != nil { // Handle error. } defer m.Close() // Cleanup.
Establish a new session connection to targetID.
pageConn, err := m.Dial(context.TODO(), targetID) if err != nil { // Handle error. } defer pageConn.Close()
Use the session connection.
pageClient := cdp.NewClient(pageConn) err = pageClient.Page.Enable(context.TODO()) // ...
If session connections are behaving unexpectedly, you can debug the session Manager by checking the error channel.
go func() { for err := range m.Err() { log.Println(err) } // Manager is closed. }()
Index ¶
Constants ¶
This section is empty.
Variables ¶
This section is empty.
Functions ¶
This section is empty.
Types ¶
type Manager ¶
type Manager struct {
// contains filtered or unexported fields
}
Manager establishes session connections to targets.
func NewManager ¶
NewManager creates a new session Manager.
The cdp.Client will be used to listen to events and invoke commands on the Target domain. It will also be used by all rpcc.Conn created by Dial.
func (*Manager) Close ¶
Close closes the Manager and all active sessions. All rpcc.Conn created by Dial will be closed.