Documentation
¶
Index ¶
- Constants
- Variables
- func NewMemoryDeviceStore(cfg map[string]config.Manager) *deviceStore
- type Handler
- func (h *Handler) GetDevice(deviceID string) (manager.NodeIdentifier, device.Device, error)
- func (h *Handler) GetDevices() ([]device.Device, error)
- func (h *Handler) Handle(payload events.NodeConnectedPayload)
- func (h *Handler) HasDevice(device2 device.Device) bool
- func (h *Handler) Init(masterUrl, nodeIdentifier string, authToken *string) error
- func (h *Handler) Name() string
- func (h *Handler) RefreshDevices(force bool) error
- func (h *Handler) RegisterDevice(data device.RegisterData) (device.Device, error)
- func (h *Handler) Run(ctx context.Context, runSocketListener bool) error
- func (h *Handler) Start() error
- func (h *Handler) StartDevice(deviceID string) error
- func (h *Handler) Stop() error
- func (h *Handler) StopDevice(deviceID string) error
- func (h *Handler) UpdateNodeDevices(nodeIdentifier manager.NodeIdentifier, managers map[string][]device.Device, ...) error
- type NodeDevice
- func (d *NodeDevice) ClearAppData(params *app.Parameter) error
- func (d *NodeDevice) ConnectionTimeout() time.Duration
- func (d *NodeDevice) Execute(data string)
- func (d *NodeDevice) GetNodeID() manager.NodeIdentifier
- func (d *NodeDevice) GetScreenshot() ([]byte, int, int, error)
- func (d *NodeDevice) HasFeature(feature string) bool
- func (d *NodeDevice) InputText(text string) error
- func (d *NodeDevice) InstallApp(params *app.Parameter) error
- func (d *NodeDevice) IsAppConnected() bool
- func (d *NodeDevice) IsAppInstalled(params *app.Parameter) (bool, error)
- func (d *NodeDevice) NodeManager() manager.Nodes
- func (d *NodeDevice) PressKey(key string) error
- func (d *NodeDevice) ReadLogs(lines int) ([]string, error)
- func (d *NodeDevice) ReadLogsSince(since string, lines int) ([]string, error)
- func (d *NodeDevice) RunNativeScript(script []byte)
- func (d *NodeDevice) Send(script []byte) error
- func (d *NodeDevice) SetDeviceState(state string)
- func (d *NodeDevice) StartApp(_ *device.DeviceConfig, appParams *app.Parameter, sessionId string, ...) error
- func (d *NodeDevice) StartRecording(path string) error
- func (d *NodeDevice) StartVideo(ctx context.Context, opts device.VideoOptions) (device.VideoStream, error)
- func (d *NodeDevice) StopApp(params *app.Parameter) error
- func (d *NodeDevice) StopRecording() error
- func (d *NodeDevice) Swipe(fromX, fromY, toX, toY int, duration time.Duration) error
- func (d *NodeDevice) Tap(x, y int) error
- func (d *NodeDevice) UninstallApp(params *app.Parameter) error
- func (d *NodeDevice) UpdateDeviceInfos(parameter map[string]string)
Constants ¶
const ( Manager = "node" // UpdateInterval is the safety net: nodes push every change of their // device list, so the master only asks them this often. UpdateInterval = 5 * time.Minute )
const ConnectionTimeout = 10 * time.Second
Variables ¶
var ( ErrManagerNotFound = fmt.Errorf("manager not found") ErrDeviceNotFound = fmt.Errorf("device not found") )
Functions ¶
func NewMemoryDeviceStore ¶
Types ¶
type Handler ¶
type Handler struct {
// contains filtered or unexported fields
}
Handler manages the devices of all nodes on the master.
func NewHandler ¶
NewHandler returns the handler of the node devices. The video streams of its devices pair through the rendezvous of nm when nm provides one (videostream.Provider), through a private one otherwise.
func (*Handler) Handle ¶
func (h *Handler) Handle(payload events.NodeConnectedPayload)
func (*Handler) Init ¶
Init registers the node events, restores the stored node devices and asks the nodes for their current ones. The arguments are the node settings of the other handlers; the master side needs none of them.
func (*Handler) RefreshDevices ¶
RefreshDevices fetches the device lists of all nodes over RPC. Nodes push their changes (UpdateNodeDevices), so this runs when the master starts, when a node connects or drops, and every UpdateInterval as a safety net.
func (*Handler) RegisterDevice ¶
func (*Handler) StartDevice ¶
func (*Handler) StopDevice ¶
func (*Handler) UpdateNodeDevices ¶ added in v1.1.0
func (h *Handler) UpdateNodeDevices(nodeIdentifier manager.NodeIdentifier, managers map[string][]device.Device, sentAt int64) error
UpdateNodeDevices applies a device list a node pushed. Pushes older than the last applied one (sentAt, node clock) are dropped, and so are pushes of a node that isn't connected: it is refreshed completely when it connects.
type NodeDevice ¶
NodeDevice is a device that lives on a node. It reports the identity the node announced and forwards everything else to the node through the node manager.
func (*NodeDevice) ClearAppData ¶ added in v1.1.0
func (d *NodeDevice) ClearAppData(params *app.Parameter) error
func (*NodeDevice) ConnectionTimeout ¶
func (d *NodeDevice) ConnectionTimeout() time.Duration
func (*NodeDevice) Execute ¶
func (d *NodeDevice) Execute(data string)
Execute is skipped when the node manager has no features.
func (*NodeDevice) GetNodeID ¶
func (d *NodeDevice) GetNodeID() manager.NodeIdentifier
func (*NodeDevice) GetScreenshot ¶
func (d *NodeDevice) GetScreenshot() ([]byte, int, int, error)
func (*NodeDevice) HasFeature ¶
func (d *NodeDevice) HasFeature(feature string) bool
HasFeature is false when the node manager has no features.
func (*NodeDevice) InputText ¶ added in v1.1.0
func (d *NodeDevice) InputText(text string) error
InputText implements device.InputCapable by forwarding to the node.
func (*NodeDevice) InstallApp ¶
func (d *NodeDevice) InstallApp(params *app.Parameter) error
func (*NodeDevice) IsAppConnected ¶
func (d *NodeDevice) IsAppConnected() bool
func (*NodeDevice) IsAppInstalled ¶
func (d *NodeDevice) IsAppInstalled(params *app.Parameter) (bool, error)
func (*NodeDevice) NodeManager ¶
func (d *NodeDevice) NodeManager() manager.Nodes
func (*NodeDevice) PressKey ¶ added in v1.1.0
func (d *NodeDevice) PressKey(key string) error
PressKey implements device.InputCapable by forwarding to the node.
func (*NodeDevice) ReadLogs ¶ added in v1.1.0
func (d *NodeDevice) ReadLogs(lines int) ([]string, error)
ReadLogs implements device.LogReader by forwarding to the node.
func (*NodeDevice) ReadLogsSince ¶ added in v1.2.0
func (d *NodeDevice) ReadLogsSince(since string, lines int) ([]string, error)
ReadLogsSince implements device.LogFollower by forwarding to the node.
func (*NodeDevice) RunNativeScript ¶
func (d *NodeDevice) RunNativeScript(script []byte)
RunNativeScript is skipped when the node manager has no native scripts.
func (*NodeDevice) Send ¶
func (d *NodeDevice) Send(script []byte) error
Send forwards the action to the node. The node reports no delivery result.
func (*NodeDevice) SetDeviceState ¶
func (d *NodeDevice) SetDeviceState(state string)
func (*NodeDevice) StartApp ¶
func (d *NodeDevice) StartApp(_ *device.DeviceConfig, appParams *app.Parameter, sessionId string, nodeUrl string) error
StartApp starts the app on the node with the connection settings stored for the device; the config argument of the caller does not apply to node devices.
func (*NodeDevice) StartRecording ¶
func (d *NodeDevice) StartRecording(path string) error
func (*NodeDevice) StartVideo ¶ added in v1.1.0
func (d *NodeDevice) StartVideo(ctx context.Context, opts device.VideoOptions) (device.VideoStream, error)
StartVideo implements device.VideoStreamer. The node starts the stream and dials back to the master, which pairs the socket through the rendezvous.
func (*NodeDevice) StopRecording ¶
func (d *NodeDevice) StopRecording() error
func (*NodeDevice) Swipe ¶ added in v1.1.0
func (d *NodeDevice) Swipe(fromX, fromY, toX, toY int, duration time.Duration) error
Swipe implements device.InputCapable by forwarding to the node.
func (*NodeDevice) Tap ¶ added in v1.1.0
func (d *NodeDevice) Tap(x, y int) error
Tap implements device.InputCapable by forwarding to the node.
func (*NodeDevice) UninstallApp ¶
func (d *NodeDevice) UninstallApp(params *app.Parameter) error
func (*NodeDevice) UpdateDeviceInfos ¶
func (d *NodeDevice) UpdateDeviceInfos(parameter map[string]string)
UpdateDeviceInfos replaces the device parameters with a copy of parameter.