Documentation ¶
Index ¶
- Constants
- Variables
- func GetVersion() string
- func Logger(logger logrus.FieldLogger) gin.HandlerFunc
- func Recovery() gin.HandlerFunc
- func RecoveryWithWriter(out io.Writer) gin.HandlerFunc
- func ZeroConfServer(ctx context.Context, name string, address string)
- type DeviceManager
- func (dm *DeviceManager) AddHandler(manager device.Handler)
- func (dm *DeviceManager) Devices() ([]device.Device, error)
- func (dm *DeviceManager) FindDevice(params *app.Parameter) device.Device
- func (dm *DeviceManager) GetDevice(id string) device.Device
- func (dm *DeviceManager) ListDevices()
- func (dm *DeviceManager) RegisterDevice(data device.RegisterData) (device.Device, error)
- func (dm *DeviceManager) Run(ctx context.Context) error
- func (dm *DeviceManager) SendAction(dev device.Device, act action.Interface) error
- func (dm *DeviceManager) SocketListener() error
- func (dm *DeviceManager) Start(dev device.Device) error
- func (dm *DeviceManager) Stop(dev device.Device) error
- func (dm *DeviceManager) StopObserver()
- type Recorder
- type Service
- type Session
- func (s *Session) Close() error
- func (s *Session) DeviceDisconnected()
- func (s *Session) GetActionTimeout() time.Time
- func (s *Session) GetAppParameter() *app.Parameter
- func (s *Session) GetDevice() device.Device
- func (s *Session) GetDeviceLock() *manager.DeviceLock
- func (s *Session) GetLastAccess() time.Time
- func (s *Session) GetLogger() *logrus.Entry
- func (s *Session) GetSessionID() string
- func (s *Session) GetStorage() manager.Storage
- func (s *Session) HandleDisconnect()
- func (s *Session) SetActionTimeout(timeout time.Duration)
- func (s *Session) SetDeviceLock(lock *manager.DeviceLock)
- func (s *Session) SetLastAccess(t time.Time)
- func (s *Session) WaitForConnection() error
- type SessionManager
- func (s *SessionManager) AddSession(session manager.Session)
- func (s *SessionManager) CreateNewSession(log *logrus.Entry, properties *device.Properties, appParameter *app.Parameter) manager.Session
- func (s *SessionManager) GetSession(sessionID string) (manager.Session, error)
- func (s *SessionManager) GetSessionDetails(sessionID string) manager.Session
- func (s *SessionManager) GetSessions() []manager.Session
- func (s *SessionManager) Run(ctx context.Context)
- func (s *SessionManager) StopSession(session manager.Session) error
- type SessionStorage
Constants ¶
View Source
const (
DeviceConnectionTimeout = 5 * time.Minute
)
View Source
const (
SessionTimeout = 1 * time.Minute
)
Variables ¶
View Source
var ( DEVICE_CONNECTION_TIMEOUT = 30 * time.Second CONNECTION_TIMEOUT = fmt.Errorf("connection timeout") ActionTimeout = 20 * time.Second )
View Source
var (
UnknownSessionError = fmt.Errorf("unknown session")
)
Functions ¶
func GetVersion ¶
func GetVersion() string
func Logger ¶
func Logger(logger logrus.FieldLogger) gin.HandlerFunc
func Recovery ¶
func Recovery() gin.HandlerFunc
Recovery returns a middleware that recovers from any panics and writes a 500 if there was one.
func RecoveryWithWriter ¶
func RecoveryWithWriter(out io.Writer) gin.HandlerFunc
RecoveryWithWriter returns a middleware for a given writer that recovers from any panics and writes a 500 if there was one.
Types ¶
type DeviceManager ¶
type DeviceManager struct {
// contains filtered or unexported fields
}
func NewDeviceManager ¶
func NewDeviceManager(logger *logrus.Logger, db *gorm.DB) *DeviceManager
func (*DeviceManager) AddHandler ¶
func (dm *DeviceManager) AddHandler(manager device.Handler)
func (*DeviceManager) FindDevice ¶
func (dm *DeviceManager) FindDevice(params *app.Parameter) device.Device
func (*DeviceManager) ListDevices ¶
func (dm *DeviceManager) ListDevices()
func (*DeviceManager) RegisterDevice ¶
func (dm *DeviceManager) RegisterDevice(data device.RegisterData) (device.Device, error)
func (*DeviceManager) SendAction ¶
func (*DeviceManager) SocketListener ¶
func (dm *DeviceManager) SocketListener() error
func (*DeviceManager) StopObserver ¶
func (dm *DeviceManager) StopObserver()
type Recorder ¶
type Recorder struct { Storage *SessionStorage Device device.Device }
type Service ¶
type Service struct {
// contains filtered or unexported fields
}
func NewService ¶
func (*Service) AddEndpoint ¶
func (s *Service) AddEndpoint(endpoint endpoints.ServiceEndpoint) error
func (*Service) RegisterHooks ¶
func (*Service) RunSlave ¶
func (g grpcSlave) DeviceList(srv action.RemoteDevice_DeviceListServer) error { logrus.Infof("DeviceList") ctx := srv.Context() for { select { case <-ctx.Done(): return ctx.Err() default: } logrus.Infof("waiting for message") _, err := srv.Recv() if err == io.EOF { logrus.Infof("EOF") return nil } if err != nil { logrus.Errorf("stream error: %v", err) return err } var deviceList []*action.Device resp := action.DeviceResponse{ Devices: deviceList, } logrus.Infof("Send Device List") if err := srv.Send(&resp); err != nil { return err } } return nil }
func (g grpcSlave) DeviceInteraction(srv action.RemoteDevice_DeviceInteractionServer) error { logrus.Infof("DeviceInteraction") ctx := srv.Context() for { select { case <-ctx.Done(): return ctx.Err() default: } _, err := srv.Recv() if err == io.EOF { return nil } if err != nil { return err } resp := action.InteractionResponse{} if err := srv.Send(&resp); err != nil { return err } } return nil }
func (g grpcSlave) ActionExecute(srv action.RemoteDevice_ActionExecuteServer) error { logrus.Infof("ActionExecute") ctx := srv.Context() for { select { case <-ctx.Done(): return ctx.Err() default: } _, err := srv.Recv() if err == io.EOF { return nil } if err != nil { return err } resp := action.Response{} if err := srv.Send(&resp); err != nil { return err } } return nil }
type Session ¶
type Session struct { SessionID string LastAccess time.Time Lock *manager.DeviceLock Recorder *Recorder DeviceProperties *device.Properties AppParameter *app.Parameter XmlDocument *xmlquery.Node Storage manager.Storage // contains filtered or unexported fields }
func (*Session) DeviceDisconnected ¶
func (s *Session) DeviceDisconnected()
func (*Session) GetActionTimeout ¶
func (*Session) GetAppParameter ¶
func (*Session) GetDeviceLock ¶
func (s *Session) GetDeviceLock() *manager.DeviceLock
func (*Session) GetLastAccess ¶
func (*Session) GetSessionID ¶
func (*Session) GetStorage ¶
func (*Session) HandleDisconnect ¶
func (s *Session) HandleDisconnect()
func (*Session) SetActionTimeout ¶
func (*Session) SetDeviceLock ¶
func (s *Session) SetDeviceLock(lock *manager.DeviceLock)
func (*Session) SetLastAccess ¶
func (*Session) WaitForConnection ¶
type SessionManager ¶
type SessionManager struct {
// contains filtered or unexported fields
}
func NewSessionManager ¶
func NewSessionManager(logger *logrus.Logger, deviceManager *DeviceManager) *SessionManager
func (*SessionManager) AddSession ¶
func (s *SessionManager) AddSession(session manager.Session)
func (*SessionManager) CreateNewSession ¶
func (s *SessionManager) CreateNewSession(log *logrus.Entry, properties *device.Properties, appParameter *app.Parameter) manager.Session
func (*SessionManager) GetSession ¶
func (s *SessionManager) GetSession(sessionID string) (manager.Session, error)
func (*SessionManager) GetSessionDetails ¶
func (s *SessionManager) GetSessionDetails(sessionID string) manager.Session
func (*SessionManager) GetSessions ¶
func (s *SessionManager) GetSessions() []manager.Session
func (*SessionManager) Run ¶
func (s *SessionManager) Run(ctx context.Context)
func (*SessionManager) StopSession ¶
func (s *SessionManager) StopSession(session manager.Session) error
type SessionStorage ¶
type SessionStorage struct { Path string SessionID string // contains filtered or unexported fields }
func NewSessionStorage ¶
func NewSessionStorage(Path, SessionID string) *SessionStorage
func (*SessionStorage) Close ¶
func (s *SessionStorage) Close() error
func (*SessionStorage) GetPath ¶
func (s *SessionStorage) GetPath() string
func (*SessionStorage) RemoteDeviceLog ¶
func (s *SessionStorage) RemoteDeviceLog(line string)
func (*SessionStorage) StoreImage ¶
func (s *SessionStorage) StoreImage(content []byte) (string, error)
func (*SessionStorage) StoreSceneGraph ¶
func (s *SessionStorage) StoreSceneGraph(data []byte) (string, error)
Source Files ¶
Click to show internal directories.
Click to hide internal directories.