Documentation ¶
Index ¶
- type BaseModule
- func (g *BaseModule) Connected() bool
- func (g *BaseModule) Logger() *logger.Logger
- func (g *BaseModule) Start() error
- func (g *BaseModule) Stop() error
- func (g *BaseModule) String() string
- func (g *BaseModule) UB() unitybridge.UnityBridge
- func (g *BaseModule) WaitForConnection(timeout time.Duration) bool
Constants ¶
This section is empty.
Variables ¶
This section is empty.
Functions ¶
This section is empty.
Types ¶
type BaseModule ¶
type BaseModule struct {
// contains filtered or unexported fields
}
BaseModule is a base implementation of the module.Module interface. It takes care of handling the connection status of the module and provides default implementations for all interface methods.
Module implementations can simply embed this or they can provide custom logic for each method (just be sure to always call the base implementation).
func NewBaseModule ¶
func NewBaseModule(ub unitybridge.UnityBridge, l *logger.Logger, name string, k *key.Key, cb result.Callback, deps ...module.Module) *BaseModule
NewBaseModule creates a new BaseModule instance with the given name and that will listen for results with the given key. The given callback, if not nil, will be called whenever a new result is received.
func (*BaseModule) Connected ¶
func (g *BaseModule) Connected() bool
Connected returns true if the module is connected, false otherwise.
func (*BaseModule) Logger ¶
func (g *BaseModule) Logger() *logger.Logger
Logger returns the Logger instance used by the module.
func (*BaseModule) Start ¶
func (g *BaseModule) Start() error
Start starts the module by starting the connection result listener.
func (*BaseModule) Stop ¶
func (g *BaseModule) Stop() error
Stop stops the module by stopping the connection result listener.
func (*BaseModule) UB ¶
func (g *BaseModule) UB() unitybridge.UnityBridge
UB returns the UnityBridge instance used by the module.
func (*BaseModule) WaitForConnection ¶
func (g *BaseModule) WaitForConnection(timeout time.Duration) bool
WaitForConnection returns the current connection status, if one is available or waits for a new one for the given timeout period. It returns true if the module is connected, false otherwise (including if the timeout period is reached or an error happens).