...
1 package playwright
2
3 type cdpSessionImpl struct {
4 channelOwner
5 }
6
7 func (c *cdpSessionImpl) Detach() error {
8 _, err := c.channel.Send("detach")
9 return err
10 }
11
12 func (c *cdpSessionImpl) Send(method string, params map[string]interface{}) (interface{}, error) {
13 result, err := c.channel.Send("send", map[string]interface{}{
14 "method": method,
15 "params": params,
16 })
17 if err != nil {
18 return nil, err
19 }
20
21 return result, err
22 }
23
24 func (c *cdpSessionImpl) onEvent(params map[string]interface{}) {
25 c.Emit(params["method"].(string), params["params"])
26 }
27
28 func newCDPSession(parent *channelOwner, objectType string, guid string, initializer map[string]interface{}) *cdpSessionImpl {
29 bt := &cdpSessionImpl{}
30
31 bt.createChannelOwner(bt, parent, objectType, guid, initializer)
32
33 bt.channel.On("event", func(params map[string]interface{}) {
34 bt.onEvent(params)
35 })
36
37 return bt
38 }
39
View as plain text