2017-01-24 15:09:23 +00:00
|
|
|
// Package tethering provides the Chrome Debugging Protocol
|
2017-02-12 04:59:33 +00:00
|
|
|
// commands, types, and events for the Tethering domain.
|
2017-01-24 15:09:23 +00:00
|
|
|
//
|
|
|
|
// The Tethering domain defines methods and events for browser port binding.
|
|
|
|
//
|
|
|
|
// Generated by the chromedp-gen command.
|
|
|
|
package tethering
|
|
|
|
|
|
|
|
// AUTOGENERATED. DO NOT EDIT.
|
|
|
|
|
|
|
|
import (
|
|
|
|
"context"
|
|
|
|
|
2017-01-26 07:28:34 +00:00
|
|
|
cdp "github.com/knq/chromedp/cdp"
|
2017-01-24 15:09:23 +00:00
|
|
|
"github.com/mailru/easyjson"
|
|
|
|
)
|
|
|
|
|
|
|
|
// BindParams request browser port binding.
|
|
|
|
type BindParams struct {
|
|
|
|
Port int64 `json:"port"` // Port number to bind.
|
|
|
|
}
|
|
|
|
|
|
|
|
// Bind request browser port binding.
|
|
|
|
//
|
|
|
|
// parameters:
|
|
|
|
// port - Port number to bind.
|
|
|
|
func Bind(port int64) *BindParams {
|
|
|
|
return &BindParams{
|
|
|
|
Port: port,
|
|
|
|
}
|
|
|
|
}
|
|
|
|
|
2017-02-12 04:59:33 +00:00
|
|
|
// Do executes Tethering.bind against the provided context and
|
|
|
|
// target handler.
|
|
|
|
func (p *BindParams) Do(ctxt context.Context, h cdp.Handler) (err error) {
|
2017-01-24 15:09:23 +00:00
|
|
|
if ctxt == nil {
|
|
|
|
ctxt = context.Background()
|
|
|
|
}
|
|
|
|
|
|
|
|
// marshal
|
|
|
|
buf, err := easyjson.Marshal(p)
|
|
|
|
if err != nil {
|
|
|
|
return err
|
|
|
|
}
|
|
|
|
|
|
|
|
// execute
|
2017-01-26 07:28:34 +00:00
|
|
|
ch := h.Execute(ctxt, cdp.CommandTetheringBind, easyjson.RawMessage(buf))
|
2017-01-24 15:09:23 +00:00
|
|
|
|
|
|
|
// read response
|
|
|
|
select {
|
|
|
|
case res := <-ch:
|
|
|
|
if res == nil {
|
2017-01-26 07:28:34 +00:00
|
|
|
return cdp.ErrChannelClosed
|
2017-01-24 15:09:23 +00:00
|
|
|
}
|
|
|
|
|
|
|
|
switch v := res.(type) {
|
|
|
|
case easyjson.RawMessage:
|
|
|
|
return nil
|
|
|
|
|
|
|
|
case error:
|
|
|
|
return v
|
|
|
|
}
|
|
|
|
|
|
|
|
case <-ctxt.Done():
|
2017-02-12 04:59:33 +00:00
|
|
|
return ctxt.Err()
|
2017-01-24 15:09:23 +00:00
|
|
|
}
|
|
|
|
|
2017-01-26 07:28:34 +00:00
|
|
|
return cdp.ErrUnknownResult
|
2017-01-24 15:09:23 +00:00
|
|
|
}
|
|
|
|
|
|
|
|
// UnbindParams request browser port unbinding.
|
|
|
|
type UnbindParams struct {
|
|
|
|
Port int64 `json:"port"` // Port number to unbind.
|
|
|
|
}
|
|
|
|
|
|
|
|
// Unbind request browser port unbinding.
|
|
|
|
//
|
|
|
|
// parameters:
|
|
|
|
// port - Port number to unbind.
|
|
|
|
func Unbind(port int64) *UnbindParams {
|
|
|
|
return &UnbindParams{
|
|
|
|
Port: port,
|
|
|
|
}
|
|
|
|
}
|
|
|
|
|
2017-02-12 04:59:33 +00:00
|
|
|
// Do executes Tethering.unbind against the provided context and
|
|
|
|
// target handler.
|
|
|
|
func (p *UnbindParams) Do(ctxt context.Context, h cdp.Handler) (err error) {
|
2017-01-24 15:09:23 +00:00
|
|
|
if ctxt == nil {
|
|
|
|
ctxt = context.Background()
|
|
|
|
}
|
|
|
|
|
|
|
|
// marshal
|
|
|
|
buf, err := easyjson.Marshal(p)
|
|
|
|
if err != nil {
|
|
|
|
return err
|
|
|
|
}
|
|
|
|
|
|
|
|
// execute
|
2017-01-26 07:28:34 +00:00
|
|
|
ch := h.Execute(ctxt, cdp.CommandTetheringUnbind, easyjson.RawMessage(buf))
|
2017-01-24 15:09:23 +00:00
|
|
|
|
|
|
|
// read response
|
|
|
|
select {
|
|
|
|
case res := <-ch:
|
|
|
|
if res == nil {
|
2017-01-26 07:28:34 +00:00
|
|
|
return cdp.ErrChannelClosed
|
2017-01-24 15:09:23 +00:00
|
|
|
}
|
|
|
|
|
|
|
|
switch v := res.(type) {
|
|
|
|
case easyjson.RawMessage:
|
|
|
|
return nil
|
|
|
|
|
|
|
|
case error:
|
|
|
|
return v
|
|
|
|
}
|
|
|
|
|
|
|
|
case <-ctxt.Done():
|
2017-02-12 04:59:33 +00:00
|
|
|
return ctxt.Err()
|
2017-01-24 15:09:23 +00:00
|
|
|
}
|
|
|
|
|
2017-01-26 07:28:34 +00:00
|
|
|
return cdp.ErrUnknownResult
|
2017-01-24 15:09:23 +00:00
|
|
|
}
|