Documentation
¶
Index ¶
- func Convert(input any, output any) error
- func CreateService(engine *Engine, objectId string, properties map[string]any) *goja.Object
- func CreateServiceProxy(vm *goja.Runtime, service *ObjectService) *goja.Object
- type Channel
- type Emitter
- func (e *Emitter[T]) Add(event string, handler func(value T)) func()
- func (e *Emitter[T]) Any(handler func(key string, value T))
- func (e *Emitter[T]) Clear(event string) int
- func (e *Emitter[T]) ClearAll() int
- func (e *Emitter[T]) Count(event string) int
- func (e *Emitter[T]) CountAll() int
- func (e *Emitter[T]) Emit(event string, value T)
- func (e *Emitter[T]) Has(event string) bool
- func (e *Emitter[T]) Remove(event string, id string)
- type Engine
- func (e *Engine) Close()
- func (e *Engine) CompileScript(name string, src string) error
- func (e *Engine) RunFunction(name string, args ...any)
- func (e *Engine) RunOnLoop(fn func(rt *goja.Runtime))
- func (e *Engine) RunScript(name string, content string)
- func (e *Engine) Runtime() *goja.Runtime
- func (e *Engine) SetOlinkServer(server IOlinkServer)
- type EngineOptions
- type Hook
- type IOlinkConnector
- type IOlinkServer
- type LogPrinter
- type Manager
- type ManagerOptions
- type NullConnector
- func (c *NullConnector) Connect(url string) error
- func (c *NullConnector) Disconnect(url string) error
- func (c *NullConnector) Node(url string) *client.Node
- func (c *NullConnector) RegisterSink(url string, sink client.IObjectSink)
- func (c *NullConnector) UnregisterSink(url string, sink client.IObjectSink)
- type NullServer
- type OLinkSource
- func (s *OLinkSource) Close()
- func (s *OLinkSource) CollectProperties() (core.KWArgs, error)
- func (s *OLinkSource) Invoke(methodId string, args core.Args) (core.Any, error)
- func (s *OLinkSource) Linked(objectId string, node *remote.Node) error
- func (s *OLinkSource) NotifyPropertyChanged(name string, value core.Any)
- func (s *OLinkSource) NotifySignal(name string, args core.Args)
- func (s *OLinkSource) ObjectId() string
- func (s *OLinkSource) SetProperty(propertyId string, value core.Any) error
- type ObjectClient
- func (o *ObjectClient) CallMethod(method string, args ...any) any
- func (c *ObjectClient) Close()
- func (o *ObjectClient) GetProperty(name string) any
- func (o *ObjectClient) ObjectId() string
- func (o *ObjectClient) OnProperty(name string, fn func(value any))
- func (o *ObjectClient) OnSignal(signal string, fn func(args ...any))
- func (o *ObjectClient) SetProperty(name string, value any)
- type ObjectClientSink
- func (s *ObjectClientSink) HandleInit(objectId string, props core.KWArgs, node *client.Node)
- func (s *ObjectClientSink) HandlePropertyChange(propertyId string, value core.Any)
- func (s *ObjectClientSink) HandleRelease()
- func (s *ObjectClientSink) HandleSignal(signalId string, args core.Args)
- func (s *ObjectClientSink) ObjectId() string
- type ObjectService
- func (o *ObjectService) CallMethod(method string, args ...any) (goja.Value, error)
- func (s *ObjectService) Close()
- func (o *ObjectService) EmitSignal(signal string, args ...any)
- func (o *ObjectService) GetMethod(method string) goja.Callable
- func (o *ObjectService) GetProperties() map[string]any
- func (o *ObjectService) GetProperty(name string) any
- func (s *ObjectService) GetProxy() *goja.Object
- func (o *ObjectService) HasMethod(method string) bool
- func (o *ObjectService) HasProperty(name string) bool
- func (s *ObjectService) ObjectId() string
- func (o *ObjectService) OnMethod(method string, v goja.Value)
- func (o *ObjectService) OnProperty(name string, fn func(value any))
- func (o *ObjectService) OnSignal(signal string, fn func(args ...any))
- func (o *ObjectService) RemoveMethod(method string)
- func (o *ObjectService) RemoveProperty(name string)
- func (o *ObjectService) SetProperties(properties map[string]any)
- func (o *ObjectService) SetProperty(name string, value any)
- type OlinkConnector
- func (c *OlinkConnector) Close()
- func (c *OlinkConnector) Connect(url string) error
- func (c *OlinkConnector) Disconnect(url string) error
- func (c *OlinkConnector) Node(url string) *client.Node
- func (c *OlinkConnector) RegisterSink(url string, sink client.IObjectSink)
- func (c *OlinkConnector) UnregisterSink(url string, sink client.IObjectSink)
- type OlinkServer
- type Script
- type World
Constants ¶
This section is empty.
Variables ¶
This section is empty.
Functions ¶
func CreateService ¶ added in v0.48.0
CreateService creates a new service with proxy wrapper
func CreateServiceProxy ¶ added in v0.48.0
func CreateServiceProxy(vm *goja.Runtime, service *ObjectService) *goja.Object
Types ¶
type Channel ¶ added in v0.45.0
type Channel struct {
// contains filtered or unexported fields
}
func (*Channel) CreateClient ¶ added in v0.45.0
func (c *Channel) CreateClient(object string) *ObjectClient
func (*Channel) DestroyClient ¶ added in v0.45.0
func (*Channel) Disconnect ¶ added in v0.45.0
func (*Channel) GetClient ¶ added in v0.45.0
func (c *Channel) GetClient(object string) *ObjectClient
type Emitter ¶ added in v0.45.0
type Emitter[T any] struct { // contains filtered or unexported fields }
func NewEmitter ¶ added in v0.45.0
func (*Emitter[T]) Add ¶ added in v0.45.0
Add adds a handler for the given event. It returns a function that can be called to remove the handler.
func (*Emitter[T]) Clear ¶ added in v0.45.0
Clear clears all handlers for the given event. It returns the number of handlers removed.
func (*Emitter[T]) ClearAll ¶ added in v0.45.0
ClearAll clears all handlers for all events. It returns the number of handlers removed.
func (*Emitter[T]) Count ¶ added in v0.45.0
Count returns the number of handlers for the given event. It returns 0 if there are no handlers.
func (*Emitter[T]) CountAll ¶ added in v0.45.0
CountAll returns the total number of handlers for all events. It returns 0 if there are no handlers.
func (*Emitter[T]) Emit ¶ added in v0.45.0
Emit triggers the handlers for the given event. It returns an error if any of the handlers return an error.
type Engine ¶ added in v0.45.0
type Engine struct {
// contains filtered or unexported fields
}
func NewEngine ¶ added in v0.45.0
func NewEngine(opts EngineOptions) *Engine
func (*Engine) CompileScript ¶ added in v0.46.2
func (*Engine) RunFunction ¶ added in v0.45.0
func (*Engine) SetOlinkServer ¶ added in v0.45.0
func (e *Engine) SetOlinkServer(server IOlinkServer)
type EngineOptions ¶ added in v0.45.0
type EngineOptions struct { WorkDir string Server IOlinkServer Connector IOlinkConnector }
type Hook ¶ added in v0.45.0
type Hook[T any] struct { // contains filtered or unexported fields }
Hook is a generic type for managing hooks
func (*Hook[T]) Add ¶ added in v0.45.0
func (h *Hook[T]) Add(hook func(v T)) func()
Add a new hook and return a function to unregister it
type IOlinkConnector ¶ added in v0.45.0
type IOlinkServer ¶ added in v0.45.0
type IOlinkServer interface { RegisterSource(source remote.IObjectSource) UnregisterSource(source remote.IObjectSource) }
type LogPrinter ¶ added in v0.45.0
type LogPrinter struct {
// contains filtered or unexported fields
}
func NewLogPrinter ¶ added in v0.45.0
func NewLogPrinter(logger *zerolog.Logger) *LogPrinter
func (*LogPrinter) Error ¶ added in v0.45.0
func (lp *LogPrinter) Error(s string)
func (*LogPrinter) Log ¶ added in v0.45.0
func (lp *LogPrinter) Log(s string)
func (*LogPrinter) Warn ¶ added in v0.45.0
func (lp *LogPrinter) Warn(s string)
type Manager ¶ added in v0.45.0
type Manager struct {
// contains filtered or unexported fields
}
func NewManager ¶ added in v0.45.0
func NewManager(opts ManagerOptions) *Manager
func (*Manager) FunctionRun ¶ added in v0.45.0
func (*Manager) ScriptStop ¶ added in v0.45.0
func (*Manager) Start ¶ added in v0.45.0
func (m *Manager) Start(netman *net.NetworkManager)
type ManagerOptions ¶ added in v0.45.0
type ManagerOptions struct {
Server IOlinkServer
}
type NullConnector ¶ added in v0.45.0
type NullConnector struct { }
func NewNullConnector ¶ added in v0.45.0
func NewNullConnector() *NullConnector
func (*NullConnector) Connect ¶ added in v0.45.0
func (c *NullConnector) Connect(url string) error
func (*NullConnector) Disconnect ¶ added in v0.45.0
func (c *NullConnector) Disconnect(url string) error
func (*NullConnector) RegisterSink ¶ added in v0.45.0
func (c *NullConnector) RegisterSink(url string, sink client.IObjectSink)
func (*NullConnector) UnregisterSink ¶ added in v0.45.0
func (c *NullConnector) UnregisterSink(url string, sink client.IObjectSink)
type NullServer ¶ added in v0.45.0
type NullServer struct { }
func NewNullServer ¶ added in v0.45.0
func NewNullServer() *NullServer
func (*NullServer) RegisterSource ¶ added in v0.45.0
func (c *NullServer) RegisterSource(sink remote.IObjectSource)
func (*NullServer) UnregisterSource ¶ added in v0.45.0
func (c *NullServer) UnregisterSource(sink remote.IObjectSource)
type OLinkSource ¶ added in v0.45.0
type OLinkSource struct {
// contains filtered or unexported fields
}
func NewOLinkSource ¶ added in v0.45.0
func NewOLinkSource(service *ObjectService) *OLinkSource
func (*OLinkSource) Close ¶ added in v0.45.0
func (s *OLinkSource) Close()
func (*OLinkSource) CollectProperties ¶ added in v0.45.0
func (s *OLinkSource) CollectProperties() (core.KWArgs, error)
func (*OLinkSource) Linked ¶ added in v0.45.0
func (s *OLinkSource) Linked(objectId string, node *remote.Node) error
func (*OLinkSource) NotifyPropertyChanged ¶ added in v0.45.0
func (s *OLinkSource) NotifyPropertyChanged(name string, value core.Any)
func (*OLinkSource) NotifySignal ¶ added in v0.45.0
func (s *OLinkSource) NotifySignal(name string, args core.Args)
func (*OLinkSource) ObjectId ¶ added in v0.45.0
func (s *OLinkSource) ObjectId() string
func (*OLinkSource) SetProperty ¶ added in v0.45.0
func (s *OLinkSource) SetProperty(propertyId string, value core.Any) error
type ObjectClient ¶ added in v0.45.0
type ObjectClient struct {
// contains filtered or unexported fields
}
func NewObjectClient ¶ added in v0.45.0
func NewObjectClient(channel *Channel, objectId string) *ObjectClient
func (*ObjectClient) CallMethod ¶ added in v0.45.0
func (o *ObjectClient) CallMethod(method string, args ...any) any
func (*ObjectClient) Close ¶ added in v0.45.0
func (c *ObjectClient) Close()
func (*ObjectClient) GetProperty ¶ added in v0.45.0
func (o *ObjectClient) GetProperty(name string) any
func (*ObjectClient) ObjectId ¶ added in v0.45.0
func (o *ObjectClient) ObjectId() string
func (*ObjectClient) OnProperty ¶ added in v0.45.0
func (o *ObjectClient) OnProperty(name string, fn func(value any))
func (*ObjectClient) OnSignal ¶ added in v0.45.0
func (o *ObjectClient) OnSignal(signal string, fn func(args ...any))
func (*ObjectClient) SetProperty ¶ added in v0.45.0
func (o *ObjectClient) SetProperty(name string, value any)
SetProperty
type ObjectClientSink ¶ added in v0.45.0
type ObjectClientSink struct {
// contains filtered or unexported fields
}
func NewObjectClientSink ¶ added in v0.45.0
func NewObjectClientSink(client *ObjectClient) *ObjectClientSink
func (*ObjectClientSink) HandleInit ¶ added in v0.45.0
func (*ObjectClientSink) HandlePropertyChange ¶ added in v0.45.0
func (s *ObjectClientSink) HandlePropertyChange(propertyId string, value core.Any)
func (*ObjectClientSink) HandleRelease ¶ added in v0.45.0
func (s *ObjectClientSink) HandleRelease()
func (*ObjectClientSink) HandleSignal ¶ added in v0.45.0
func (s *ObjectClientSink) HandleSignal(signalId string, args core.Args)
func (*ObjectClientSink) ObjectId ¶ added in v0.45.0
func (s *ObjectClientSink) ObjectId() string
type ObjectService ¶ added in v0.45.0
type ObjectService struct {
// contains filtered or unexported fields
}
func NewObjectService ¶ added in v0.45.0
func NewObjectService(engine *Engine, objectId string, properties map[string]any) *ObjectService
func (*ObjectService) CallMethod ¶ added in v0.45.0
func (*ObjectService) Close ¶ added in v0.45.0
func (s *ObjectService) Close()
func (*ObjectService) EmitSignal ¶ added in v0.45.0
func (o *ObjectService) EmitSignal(signal string, args ...any)
func (*ObjectService) GetMethod ¶ added in v0.45.0
func (o *ObjectService) GetMethod(method string) goja.Callable
GetMethod return method
func (*ObjectService) GetProperties ¶ added in v0.45.0
func (o *ObjectService) GetProperties() map[string]any
func (*ObjectService) GetProperty ¶ added in v0.45.0
func (o *ObjectService) GetProperty(name string) any
func (*ObjectService) GetProxy ¶ added in v0.48.0
func (s *ObjectService) GetProxy() *goja.Object
GetProxy returns the proxy object for this service
func (*ObjectService) HasMethod ¶ added in v0.45.0
func (o *ObjectService) HasMethod(method string) bool
HasMethod
func (*ObjectService) HasProperty ¶ added in v0.45.0
func (o *ObjectService) HasProperty(name string) bool
HasProperty
func (*ObjectService) ObjectId ¶ added in v0.45.0
func (s *ObjectService) ObjectId() string
func (*ObjectService) OnMethod ¶ added in v0.45.0
func (o *ObjectService) OnMethod(method string, v goja.Value)
func (*ObjectService) OnProperty ¶ added in v0.45.0
func (o *ObjectService) OnProperty(name string, fn func(value any))
func (*ObjectService) OnSignal ¶ added in v0.45.0
func (o *ObjectService) OnSignal(signal string, fn func(args ...any))
func (*ObjectService) RemoveMethod ¶ added in v0.48.0
func (o *ObjectService) RemoveMethod(method string)
RemoveMethod removes a method from the service
func (*ObjectService) RemoveProperty ¶ added in v0.48.0
func (o *ObjectService) RemoveProperty(name string)
RemoveProperty removes a property from the service
func (*ObjectService) SetProperties ¶ added in v0.45.0
func (o *ObjectService) SetProperties(properties map[string]any)
func (*ObjectService) SetProperty ¶ added in v0.45.0
func (o *ObjectService) SetProperty(name string, value any)
type OlinkConnector ¶ added in v0.45.0
type OlinkConnector struct {
// contains filtered or unexported fields
}
func NewOlinkConnector ¶ added in v0.45.0
func NewOlinkConnector() *OlinkConnector
func (*OlinkConnector) Close ¶ added in v0.45.0
func (c *OlinkConnector) Close()
func (*OlinkConnector) Connect ¶ added in v0.45.0
func (c *OlinkConnector) Connect(url string) error
Connect connects to a given url and returns a connection id. The connection id can be used to disconnect from the server using Disconnect.
func (*OlinkConnector) Disconnect ¶ added in v0.45.0
func (c *OlinkConnector) Disconnect(url string) error
Disconnect closes a connection to the server. The connection id is the string returned when connecting to the server using Connect. If the connection id is not found, this function does nothing and returns nil.
func (*OlinkConnector) Node ¶ added in v0.45.0
func (c *OlinkConnector) Node(url string) *client.Node
func (*OlinkConnector) RegisterSink ¶ added in v0.45.0
func (c *OlinkConnector) RegisterSink(url string, sink client.IObjectSink)
func (*OlinkConnector) UnregisterSink ¶ added in v0.45.0
func (c *OlinkConnector) UnregisterSink(url string, sink client.IObjectSink)
type OlinkServer ¶ added in v0.45.0
type OlinkServer struct {
// contains filtered or unexported fields
}
func NewOlinkServer ¶ added in v0.45.0
func NewOlinkServer() *OlinkServer
func (*OlinkServer) Close ¶ added in v0.45.0
func (s *OlinkServer) Close()
func (*OlinkServer) RegisterSource ¶ added in v0.45.0
func (s *OlinkServer) RegisterSource(source remote.IObjectSource)
func (*OlinkServer) ServeHTTP ¶ added in v0.45.0
func (s *OlinkServer) ServeHTTP(w http.ResponseWriter, r *http.Request)
func (*OlinkServer) UnregisterSource ¶ added in v0.45.0
func (s *OlinkServer) UnregisterSource(source remote.IObjectSource)
type Script ¶
type World ¶ added in v0.45.0
type World struct {
// contains filtered or unexported fields
}
func (*World) CreateChannel ¶ added in v0.45.0
func (*World) CreateService ¶ added in v0.45.0
func (*World) GetChannel ¶ added in v0.45.0
func (*World) GetService ¶ added in v0.45.0
func (w *World) GetService(object string) *ObjectService