Documentation
¶
Overview ¶
Package wire is the protocol between the host and the on-device agents.
One TCP connection carries everything in both directions. Each message is a single line of JSON. A message may carry binary data (a screenshot): it then has a "bin" field with the byte count, and that many raw bytes follow the newline.
The host sends requests: {"id":7,"op":"tap","x":100,"y":200} The agent answers each: {"id":7,"ok":true,...} or {"id":7,"ok":false,"error":"..."} The agent also pushes events without being asked (no "id"):
{"ev":"changed","seq":41} the UI changed (an accessibility event arrived)
{"ev":"settled","seq":41} no change for the quiet window since seq 41
The host never polls: it waits on these events.
Index ¶
- type AgentError
- type Conn
- func (c *Conn) Call(op string, params map[string]any, timeout time.Duration) (*Msg, error)
- func (c *Conn) Close() error
- func (c *Conn) Done() <-chan struct{}
- func (c *Conn) Err() error
- func (c *Conn) Hello() *Msg
- func (c *Conn) HelloVersion() string
- func (c *Conn) Seq() int64
- func (c *Conn) SettledSeq() int64
- func (c *Conn) Subscribe() chan *Msg
- func (c *Conn) Unsubscribe(ch chan *Msg)
- type Msg
- type ReplyTimeout
Constants ¶
This section is empty.
Variables ¶
This section is empty.
Functions ¶
This section is empty.
Types ¶
type AgentError ¶
AgentError is an error the agent reported for a request.
func (*AgentError) Error ¶
func (e *AgentError) Error() string
type Conn ¶
type Conn struct {
// contains filtered or unexported fields
}
Conn is a connection to one agent.
func (*Conn) Call ¶
Call sends a request and waits for its answer. params is merged into the request.
func (*Conn) HelloVersion ¶
HelloVersion is the agent build version from its greeting.
func (*Conn) SettledSeq ¶
SettledSeq is the change sequence number the latest "settled" event covered.
func (*Conn) Unsubscribe ¶
type Msg ¶
type Msg struct {
ID int64 `json:"id,omitempty"`
OK bool `json:"ok,omitempty"`
Error string `json:"error,omitempty"`
Ev string `json:"ev,omitempty"`
Seq int64 `json:"seq,omitempty"`
Bin int `json:"bin,omitempty"`
Raw json.RawMessage `json:"-"`
Data []byte `json:"-"`
}
Msg is a decoded message. Raw keeps the full JSON so callers can decode op-specific fields.
type ReplyTimeout ¶ added in v0.5.0
ReplyTimeout means the request was sent but the agent's answer did not arrive.
func (*ReplyTimeout) Error ¶ added in v0.5.0
func (e *ReplyTimeout) Error() string