gcdmessage

package
v1.0.15 Latest Latest
Warning

This package is not in the latest version of its module.

Go to latest
Published: Jul 5, 2020 License: MIT Imports: 3 Imported by: 3

Documentation

Index

Constants

This section is empty.

Variables

This section is empty.

Functions

This section is empty.

Types

type ChromeApiTimeoutErr

type ChromeApiTimeoutErr struct {
}

func (*ChromeApiTimeoutErr) Error

func (cerr *ChromeApiTimeoutErr) Error() string

type ChromeDoneErr

type ChromeDoneErr struct {
}

func (*ChromeDoneErr) Error

func (cerr *ChromeDoneErr) Error() string

type ChromeEmptyResponseErr

type ChromeEmptyResponseErr struct {
}

When a ChromeTarget crashes and we have to close response channels and return nil

func (*ChromeEmptyResponseErr) Error

func (cerr *ChromeEmptyResponseErr) Error() string

type ChromeError

type ChromeError struct {
	Code    int64  `json:"code"`    // the error code
	Message string `json:"message"` // the error message
}

An error object returned from a request

type ChromeErrorResponse

type ChromeErrorResponse struct {
	Id    int64        `json:"id"`    // the request Id that this is a response of
	Error *ChromeError `json:"error"` // the error object
}

default chrome error response to an invalid request.

type ChromeRequest

type ChromeRequest struct {
	Id     int64       `json:"id"`
	Method string      `json:"method"`
	Params interface{} `json:"params,omitempty"`
}

default no-arg request

type ChromeRequestErr

type ChromeRequestErr struct {
	Resp *ChromeErrorResponse // a ref to the error response to be used to generate the user friendly error string
}

A gcd type for reporting chrome request errors

func (*ChromeRequestErr) Error

func (cerr *ChromeRequestErr) Error() string

user friendly error response

type ChromeResponse

type ChromeResponse struct {
	Id     int64       `json:"id"`
	Result interface{} `json:"result"`
}

default response object, contains the id and a result if applicable.

func SendDefaultRequest

func SendDefaultRequest(target ChromeTargeter, sendCh chan<- *Message, paramRequest *ParamRequest) (*ChromeResponse, error)

Sends a generic request that gets back a generic response, or error. This returns a ChromeResponse object.

type ChromeTargeter

type ChromeTargeter interface {
	GetId() int64
	GetApiTimeout() time.Duration
	GetSendCh() chan *Message
	GetDoneCh() chan struct{} // if tab is closed we don't want dangling goroutines.
}

type Message

type Message struct {
	ReplyCh chan *Message  // json response channel
	Id      int64          // id to map response channels to send chans
	Data    []byte         // the data for the websocket to send/recv
	Method  string         // event name type.
	Target  ChromeTargeter // reference to the ChromeTarget for events
}

An internal message object used for components and ChromeTarget to communicate back and forth

func SendCustomReturn

func SendCustomReturn(target ChromeTargeter, sendCh chan<- *Message, paramRequest *ParamRequest) (*Message, error)

Takes in a ParamRequest and gives back a response channel so the caller can decode as necessary.

type ParamRequest

type ParamRequest struct {
	Id     int64       `json:"id"`
	Method string      `json:"method"`
	Params interface{} `json:"params,omitempty"`
}

default request object that has parameters.

Jump to

Keyboard shortcuts

? : This menu
/ : Search site
f or F : Jump to
y or Y : Canonical URL