forked from mafredri/cdp
-
Notifications
You must be signed in to change notification settings - Fork 0
/
Copy pathdoc.go
43 lines (32 loc) · 985 Bytes
/
doc.go
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
/*
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.
}()
*/
package session