device

package
v0.1.2 Latest Latest
Warning

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

Go to latest
Published: Oct 6, 2022 License: Apache-2.0 Imports: 13 Imported by: 0

Documentation

Index

Constants

View Source
const (
	DefaultSocketTimeout = 1 * time.Minute
	ReceiveBufferSize    = 20 * 1024
)

Variables

View Source
var (
	DeviceNotFoundError  = errors.New("Device not found")
	ManagerNotFoundError = errors.New("Manager not found")
)
View Source
var (
	DeviceDisconnectedError = fmt.Errorf("device disconnected")
)

Functions

func GetMessageSize

func GetMessageSize(buffer []byte) uint32

func StateToString

func StateToString(state State) string

Types

type Connection

type Connection struct {
	Logger                 *logrus.Entry
	Connection             net.Conn
	ResponseChannel        chan ResponseData
	ConnectionStateChannel chan ConnectionState
	ActionChannel          chan action.Response
	ConnectionParameter    *action.Connect
}

func (*Connection) Close

func (c *Connection) Close()

func (*Connection) HandleMessages

func (c *Connection) HandleMessages(ctx context.Context)

func (*Connection) Send

func (c *Connection) Send(content []byte) error

type ConnectionState

type ConnectionState uint8
const (
	Disconnected ConnectionState = iota
	Connected
)

type Device

type Device interface {
	DeviceID() string
	DeviceIP() net.IP
	DeviceState() State
	DeviceOSName() string
	DeviceOSVersion() string
	DeviceName() string
	DeviceModel() string

	IsAppInstalled(*app.Parameter) (bool, error)
	InstallApp(*app.Parameter) error
	UninstallApp(*app.Parameter) error
	UpdateDeviceInfos() error

	NewContext() context.Context
	Cancel()
	ConnectionTimeout() time.Duration
	SetConnection(*Connection)
	Connection() *Connection
	IsAppConnected() bool

	StartApp(*app.Parameter, string, net.IP) error
	StopApp(*app.Parameter) error

	StartRecording(string) error
	StopRecording() error

	GetScreenshot() ([]byte, int, int, error)

	HasFeature(string) bool
	Execute(string)
	Lock() error
	Unlock() error
	IsLocked() bool

	SetLogWriter(LogWriter)
	Data(string, string)
	LogPerformance(checkpoint string, cpu, fps, mem float32, other string)
	Log(string, string, ...interface{})
	Error(string, string, ...interface{})
	Exception(string, string, ...interface{})
	AddActionHandler(action.ActionHandler)
	RemoveActionHandler(action.ActionHandler)
	ActionHandlers() []action.ActionHandler
	RunNativeScript(data []byte)
}

type Handler

type Handler interface {
	Name() string
	Init() error
	Start() error
	Stop() error
	StartDevice(string) error
	StopDevice(string) error
	GetDevices() ([]Device, error)
	RefreshDevices() error
	HasDevice(Device) bool
	RegisterDevice(data RegisterData) (Device, error)
}

type LogWriter

type LogWriter interface {
	LogPerformance(checkpoint string, cpu, fps, mem float32, other string)
	Data(source, data string)
	Log(source, format string, params ...interface{})
	Error(source, format string, params ...interface{})
}

type Properties

type Properties struct {
	Name         string
	DeviceID     string
	Type         string
	OS           string
	Architecture string
	App          string
}

func (*Properties) AreValid

func (p *Properties) AreValid() bool

type RegisterData

type RegisterData struct {
	ManagerType     string
	DeviceID        string
	Name            string
	DeviceOS        string
	DeviceOSVersion string
	DeviceOSInfos   string
	DeviceIP        net.IP
	Conn            *websocket.Conn
}

type ResponseData

type ResponseData struct {
	Data []byte
	Err  error
}

type State

type State uint8
const (
	StateNone State = iota
	StateUnknown
	StateShutdown
	StateRemoteDisconnected
	StateBooted
	StateLocked
)

Directories

Path Synopsis

Jump to

Keyboard shortcuts

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